I have a turret that i want to rotate randomly then stops for a sec then rotate again, for example: it suppose to rotate to the right then stops for a second or two then maybe rotate to left then stops for a second then repeat.
for example: to the right then left then left then right then maybe right or left and so on
imagine like he is searching/idling
i made this but it keeps rotating like crazy with no stops:
So “AddLocalRotation” is being done every tick here, which is about 3 times a frame.
So when you set your “Rotate Yaw”, tick says “Take this variable and apply it to the yaw 180x per second” then when it gets a new variable for “Rotate Yaw” it does the same just with the new variable of -5 to +5… 180x per second.
If you want to add a delay between turns, maybe add a boolean into “Rotate Head event”.
Say “bRotateGo” or something. Then you would use a NOT modifier to change it to opposite value every time rotate head runs.
After that put a branch in tick and check that variable, on false do nothing and on true, turn for the timer’s time.
If you would like to have it rotate slower, simply lower the range on your random float generator.
Yeah, sure. But you’ll set it up my way and learn something!
We’ll do this in a few steps here.
This should do for your needs, I think.
Oh, you can leave the branch out. But it will keep going if the turret sees a player. Make a new bool checking if it sees the player, and put it there to stop this functionality.
That’s some odd behavior, but you’re not giving me much to work with here.
Let’s see that code! Oh, and the inside of the timeline, as well. Should be an easy fix.
Okay! Sorry for the late response. Two things should fix this (one was my mistake!)
For the timeline you want it going from 0 to 1, and you have it going from 1 to 0. Though I suppose you could just switch the A and B on the LERP but that’s… strange programming philosophy.
Secondly, this is your current yaw. This should be “A” on your LERP.
For B, you want to ADD that number and your random float together. Take that output and set as “Rotate Yaw” before the timeline. You want your B to be the rotation you’re wanting to achieve, not how much + or -.