Download

Tower animations for a tower defense game

Hi,
I’m working on a small tower defense game and I have a few general questions around tower animations.
So I have tower with a skeleton and yaw and pitch rotation animations as well as fire animation. See the attached screenshot.

tower2.png

The questions are:

  1. Let’s say that I want to start with just yaw rotation to make my tower track its targets. How can I use the “Find Look at Rotation” with my animation to make the tower face its target while the target is moving around the tower? And is this the right way to achieve what I want?
  2. How do I stop/pause the rotation animation at some point, play the fire animation and then continue the rotation animation?
  3. How do I blend yaw and pitch rotation to make my tower able to track flying targets as well?

I’ve been experimenting with blend spaces and aim offsets but I can’t seem to be able to put the animations correctly on the gird to achieve what I want. Also I’m not sure if I really need such blending, if I can do this tracking with just animation sequences.

I’d be very grateful if someone can give me a hand.

Thank you.

Aim offset/Blendspace - that’s not what you want for a turret.

Separate the model into two, where the ‘head’ can just be rotated. (Or simply find a way to rotate the head bone only). Program the rotation of that (3d look at actor)](Set pawn rotation to look at another actor - UE4 AnswerHub), using lerp smoothing, rather than animating it

You could then even read the values from a detailed pre-animated ‘swing 180 z’ animation as your target speed that it rotates to face the target with. You get 3d tracking with that. Not sure how to read animation values in BPs, I’d make a c++ function for that.

For 2) you can simply stop rotating it on firing (when it recognizes a target), and then set a timer (e.g. 1 second) with a new custom event to start rotating it again, all by setting a bool variable to control the rotation.

So you will need to add some BP logic to the On Event Tick of the turret actor, based on tracing for a target actor, and whether you have a current target, and the time delay for firing. Try searching the Answerhub for examples of “timer”, “line trace” etc. if you get stuck.

Thanks for your answer.
I’ll try to rotate the yaw joint only.

Is there a way to play an animation on just part of the skeleton?
In my case I’d like to try to play the fire animation on the upper part of the tower while I rotate the yaw bone manually.

Thanks.

https://www.youtube.com/watch?v=C16vlfe3pXc&list=PLZlv_N0_O1gaCL2XjKluO7N2Pmmw9pvhE

The Tutorial with the Punching Animation Setup should help you :slight_smile:

Thanks KenshiHH, that was useful.

OK, so I’m trying to manually rotate one of the bones while I play the fire animation on the other part of the skeleton.
Here’s my setup:

transform_bone.png

transform_bone_details.png

However when I change the value of the Yaw variable, nothing happens. No rotation is applied to the bone I selected.
What am I doing wrong?

I agree with Fish and Chips. I’d make the base a separate object. Then Code or BP the top to look at the target, lerping it into position from it’s previous position over a variable time period. Longer lerp for greater movement, shorter lerp for a small movement. Some of the math is a bit complex. And you’ll need to account for it not rotating into silly positions like straight up or straight down. I prototyped something like that in SM: Web of Shadows. I had to get a programmer to coach me on the math though.