Swinging the axe – Attack Animation HowTo

Posted by (twitter: @gipzo_)
December 19th, 2016 9:29 am

Hello again,

I’m continuing postmortem posts about our game – Cure4Life.

And in this post I want to explain how we did axe attack animation.
Other weapons behave simpler as they don’t have any animation at all :)

title

Unity 5.5 project archive

Hierarchy

First, let me show how weapons are connected to the Player and how each Weapon is organised:

hierarchy

Hero has Weapons game object that is positioned in the middle of his chest.
This way Weapons object can be rotated to aim weapon in some particular direction:

weapon_rotation
(red dot is the pivot position of Weapons object)

This position is independent of weapon animation and it is also useful to know our weapon aiming to decide which enemies we hit :)

Inside Weapons game object we have separate objects for each weapon.
Each weapon contains separate object for it’s sprite and other effects.

For example this is Cure4Life hierarchy:

cure4life_hierarchy

Animation

Animation-wise axe is simple:

We have 3 animation:

  1. Idle – just one frame
  2. AxeSwing1 – axe swings from top to bottom
  3. AxeSwing2 – axe swings from bottom to the top

axe_swing_1    axe_swing_2

The interesting part is Animation controller.

We added Fire trigger and set up Idle animation as default.
There are 3 transitions: Idle->AxeSwing2, AxeSwing2->AxeSwing1, AxeSwing1->AxeSwing2.
They all are configured the same:

axe_animation_trigger
No exit time, zero transition duration and they are activated on Fire trigger.
This way, each time Fire is triggered, animation will switch between AxeSwing1 and AxeSwing2:

animation_controller

Particle System

Another crucial part of attack animation is swing particles:

swing_particles

This is done mostly with default particle system and particle texture, which consists of 4 frames.

Here are axe’s swing particle system setting with some explanation:

particles_rotation

particles

particles_animation

particles_renderer

Making it Move

Activating animation and particle system is pretty simple:

Animator.SetTrigger ("Fire");
Particles.Emit (Random.Range (1, 3));

Add some timeouts and input logic and we get this:

final_result

I hope this post is somewhat useful :)
Here full Unity 5.5 project archive – Download Sample Project.

P.S. Don’t forget to play, rate and comment our game – Cure4Life 😉

Tags: , ,


Leave a Reply

You must be logged in to post a comment.

[cache: storing page]