AI actor turn back start position

Hi,

how can you do that in blueprint: When the character is out of reach of the AI ​​actor, the AI ​​should turn (rotate) back after 5 seconds to its starting position.

Hey,

quick question, how do you control the behavior of the AI Actor? Do you use Behavior Trees or are you using the Actor or AI Controller Blueprint to control its behavior?

Also what do you use to detect the other character? The perception system of Unreal or did you create your own system?

Depending on that how you can achive this varies.

Also what part from what you want to achieve do you have problems with? Just the timing part or more?

I have already developed a perception system in blueprint (ohne Behavior Trees). I only need: rotate back to start position after 5 seconds

Ok,

so I would use a timer then. There are two Nodes you could use to achieve that. The “Set Timer by Function” and the “Set Timer by Event” Nodes. These Nodes call a Function or Event after a given amount of time and can be reseted. More here

You should create a variable that holds the Timerhandle you recieve from the "Set Timer Node. When the AI Actor looses sight, you call a “Set Timer” node. And set the Timerhandle variable to that returned Timerhandle. When the AI Actor regains sight you check if a timer exists and then delete it, if it does using the “Clear Timer” or “Delete Timer” Node (sorry don’t know the name of that node) and clear the Timerhandle variable.

The Function or the Event which is called after the time reaches zero than handles the rotation backwards.

but how to do that in blueprint: rotate back to start position as soon as AI actor loses sight?

You can use “Rotate to face BB entry” task and assign it a key of type rotator from your blackboard.

You can set the needed angle of the key in the blackboard where needed.

3dRavens method would need you to implent it using behaviour trees. Because you are not usign any, I suggest that you use the “Move Component To” Node to rotate back in the Event called from the timer.

This node moves an component of the actor to a certain position and roation. If the component you move is the root component, you move the entire actor. Also the node comes with built in interpolation so it rotates the actor over a given time. Makes it look smooth and it will not jump to the rotation as the “Set Rotation” Node would do it.

To implement it you would need a variable wich holds the default rotation of the actor. Which you then use as the rotation for the “Move Component To” node.
You also need to use the current location of the actor as the traget location for the “Move Component To” node. If you do not, it will move the entire actor to the origin.

hi there :slight_smile:

here is a simple solution, but nav mesh or a real navigation would be better…



and here is the result :smiley:

hope this helps you on your way :slight_smile:

cheers :vulcan_salute:

2 Likes

Many thanks for your very good solution! :slightly_smiling_face:

hi,
no problem, best would be to combine it with nav mesh and blackboard :slight_smile:

happy coding :vulcan_salute:

1 Like