Player Setup Part 7

Objective: Set up Attacking with Animation

Following on from Jumping, lets take the above spritesheet and create an attack. Start by slicing up the spritesheet as previously done then create the Player animation and transitions. Unlike the Jump transition parameter, we will use a trigger instead of a bool for the attack. This will allow an auto transition back to idle after the attack is finished.

Next inside the PlayerAnimation script, create a public Attack method that sets the Animator trigger for the attack.

Inside the Player script create an Attack method and inide this check for a mouse left-click and if the Player IsGrounded. If so called the PlayerAnimation Attack method. Call the Players Attack method inside the Update method after calling the Movement method.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store