Turret Randomly Rotate like he is Idling

Hey there!

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:

Hey @Abdalah.Salameh!

So “AddLocalRotation” is being done every tick here, which is about 3 times a frame. :stuck_out_tongue:
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. :slight_smile:

1 Like

Thanks mate! yah that tick is no go :sweat_smile:

if you have the time would you like to show me how to set it up? a simple sketch would do
because I’m kinda confused…

Hi there @Abdalah.Salameh,

This topic has been moved from International to Programming & Scripting: Blueprint.

When posting, please review the categories to ensure your topic is posted in the most relevant space.

Thanks and happy developing!

1 Like

Yeah, sure. But you’ll set it up my way and learn something! :joy:

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.

3 Likes

Sure, your way or the highway… as long as there’s no detour to Narnia! :upside_down_face:

i fallowed the steps, first it wasn’t working until i change the branch to from false to true just to test things out

image

now its shaking like he’s having an ■■■■■■ lol

That’s some odd behavior, but you’re not giving me much to work with here. :stuck_out_tongue:
Let’s see that code! Oh, and the inside of the timeline, as well. Should be an easy fix. :slight_smile:

sure thing bud!

inside the time line

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. :stuck_out_tongue: 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.
image

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 -. :slight_smile:

1 Like

no problem mate!

No problem mate! it works !!

Thank you for your time!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.

1 Like