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
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.
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
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.
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.
Inside the Firing state, we play this animation graph:
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.