Post tutorial Report RSS Unreal Engine 4 - Tank animation setup with player controlled turret join

In Tank Brawl 2, player uses right stick to control the turret and left stick to control the tank movement. The result is that the turret rotation is controlled by code whereas all other component movements are control by animation assets such as shooting, braking, turning, accelerating

Posted by on - Intermediate Animation

Turret join controlled by player right stick input

Notice how the tank recoils correctly regardless of which direction the turret is facing. We achieve this by setting up the whole tank as one skeletal mesh and its turret base have three joins: PreCode -> Code -> PostCode.

Tank's skeletal join tree


The Code joins rotation is completely controlled by code ( i.e player's input right stick ), all other joins are controlled normally by animation assets as shown in this root anim-graph

Tank root animation graph

How does this help ? Well, imagine if player turns the turret 90 degree right. Then we look at the following scenario:

- Tank Brake, Turret nudge forward relative to tank hull. Artist will need to animate this nudge movement on the PreCode Turret joins as we want the turret always nudge to the tank's front regardless of its angle.

- Tank Shoot: The whole turret recoils back ward relative to where it's facing. In this case the artist will put this recoil movement in the "PostCode" turret joins

The State Machine

Inside the state machine is where we trigger all the animations.

Tank's animation state machine

The transition to Firing, Turning Left..etc state are triggered whenever the tank turn, shoot or brake and when the relevant animation finishes we return to the "Check" conduit to transition again to the appropriate state.

Fire Animation

Inside the Firing state, we play this animation graph:

Tank firing state

To make the tank hull recoils correctly when cannon fire with turret angled at any direction, artist create four recoil animation for the hull: Recoil Forward, Recoil Back, Recoil Left and Recoil Right. When the tank fire we calculate the angle of the turret facing compare to tank's hull forward direction and then blend between 2 of the 4 animations above. For example if the turret is facing 45 degree North-East we blend 50% of Front Recoil and 50% of Right Recoil and 0% all the other 2.

Post comment Comments
MrEmjeR
MrEmjeR

Nicely done!

Reply Good karma Bad karma+2 votes
Post a comment

Your comment will be anonymous unless you join the community. Or sign in with your social account: