Player Setup Part 7

Simon Leen
Sep 22, 2021

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.

--

--