![]() ![]() Since we’re working on melee attacks, obviously, we’ll need enemies to test out our attacks. Save all your script and go back to Unity. Rigidbody.MovePosition(rigidbody.position + movement * movementSpeed * Time.fixedDeltaTime) ![]() Hf = movement.x > 0.01f ? movement.x : movement.x 0.01f ? movement.y : movement.y < -0.01f ? 1 : 0 Movement.y = Input.GetAxisRaw("Vertical") ![]() Movement.x = Input.GetAxisRaw("Horizontal") Start is called before the first frame update Public class PlayerMovement : MonoBehaviour Now that we’re down with Player animation and Animator, let’s proceed to create the script to control our player attacks and its animations.Ĭreate a new C# script and name it PlayerAttack.cs then assign it to your Player game object. Next, we’re going to create transitions from all of our previous animations to our attack animations.įor Any State to Attack Up, set the condition, Vertical greater than 0.1 and Is_attacking to true.įor Attack Up to Idle, set the condition, Vertical less than 0.1 and Is_attacking to false.įor Any State to Attack Down, set the condition, Vertical less than -0.1, Is_attacking to true, and Is_Moving_Side to false.įor Attack Down to Idle, set the condition, Vertical greater than -0.1 and Is_attacking to false.įor Any State to Attack Side, set the condition, Horizontal greater than 0.1, Is_attacking to true, and Is_Moving_Side to true.įor Attack Side to Idle, set the condition, Horizontal less than 0.1 and Is_attacking to false. Next, select Parameters tab, then click on the plus button and select Bool to create a boolean animator parameter.Ĭlick again the plus button and select Bool and name the parameter Is_Moving_Side. Open your animator window by going to Window Tab > Animation > Animator. Now that we have set up our player attack animations, let’s proceed to our animator and create a new parameter to help our animator change from either idle animation to attack animation or walking to attacking. You should have the following animations. Drag the sprites into animation timeline.Look for folders hero-attack-back and hero-attack-side.Move the second keyframe in 0:10 and move the last keyframe in 0:20.Ĭreate new animations for Attack_Up and Attack_Side. Next, adjust the keyframes in the timeline. Next, go to your project window and look for the folder hero-attack-front and drag all the sprites into the animation timeline. ![]() Next, select the drop-down menu for the list of animations. Make sure you select your Player object and go to your animation window. Since we have already created a script for our player, let’s go back to our animation window (CTRL + 6) and add create animations. If you have already followed our previous lesson then you should be able to make your character move around the platform. Read more: Unity 2D Animation: Top-Down Unity Player Movement If by any chance, you haven’t followed the said tutorial, we suggest reading it before proceeding with this tutorial. **Īs always I will have a link to the most recent demo on my website soon.We’ll be using the same project that we have created in the last Unity tutorial which is the top-down player movement tutorial. coming in the next few updates I will begin to flesh out the game world to allow for better exploration and begin to integrate more GUI elements into the game as well. ** Please note the frame rate is due to my bad capture software, you can test to see how smooth the game actually is, capping way over the 60fps mark which is great because I can still add heaps and heaps of features and beautiful landscapes. I have also started implementation of Horse riding for faster transport around the game world. Player has enhanced combat movement with the Axe with better animation lineup and better syncing with mecanim to allow more responsive movement - Also Dodging is now implemented to allow faster reactions to evade enemies strikes.įeet IK now works a lot better and requires less memory to process - shown from the profiler readout. In this update I have introduced Lock on to Enemies to allow easier strafing and also updated the player model.Įnemies can now pursue you faster and more accurately with new Falling states.Įnemies now have their own dependent GUI's which show how much health they have and also their enemy type, in this demo's case they are "Thugs". ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |