In part 4 of this Unity3D tutorial we add Enemy AI. The enemy will walk from edge to edge of a platform as long as it's alive. This sort of enemy movement can be seen in many 2D Platformer games like Mario.
There is a dependency on the toVector2 function we wrote here: • Unity Extension Method Tutorial
Visit my website to see the code: http://www.devination.com/2015/07/uni...
Twitter: / devination3d
Google+ Community: https://plus.google.com/communities/1...
Facebook: / unity3dtutorialsbydevin
Time Breakdown:
0:30 - Updating API from Unity 4.6 to Unity 5
1:45 - Setting up the enemy sprites
2:38 - Locking Layers to avoid accidentally selecting the Canvas
3:40 - Setting up the Enemy walk anim
4:38 - Begin Enemy script
6:56 - Explanation of why we need myWidth for Linecast
9:10 - Setting up isGrounded Linecast check
12:35 - Use isGrounded check to flip the enemy if he gets to an edge
15:52 - Changing move direction to be in local space to the enemy
16:45 - Adding an isBlocked check for hitting walls
17:21 - Using ExtensionMethod .toVector2() to add a Vector2 and a Vector3: • Unity Extension Method Tutorial
20:20 - Using myHeight to Linecast from middle left of enemy instead of bottom left corner
22:24 - Demonstration of enemy movement fully working
On this page of the site you can watch the video online Unity Platformer Tutorial - Part 4 - Enemy Movement with a duration of hours minute second in good quality, which was uploaded by the user Devin Curry 12 July 2015, share the link with friends and acquaintances, this video has already been watched 60,356 times on youtube and it was liked by 546 viewers. Enjoy your viewing!