How to make a character perform a 180°?

Hello there :slight_smile:

I have a character BP (not controlled by a player). This actor always move forward (every tick move along the forward vector).
I want this actor to perform a 180° everytime he hit something (via hit event).
My first thought was to use “add controller yaw input”, but for some reason it does not apply to my actor.
Then I tried with “set world rotation”, but it seems to turn my mesh but not the forward vector. I also tried with “set control rotation” but I have some weird results.

How would you guys manage to do that ?

Thanks in advance

Set Actor Rotation?

It really depends on how the movement is applied. You may need to rotatte the character AND reverse the movement.

Thanks for your answer. I’ll try “Set actor rotation” as soon as I get home.

For your second sentence, how would you reverse the movement ?

Whatever gives the actor its original movement can surely be copied and reversed. Depends on what you are working on of course.

I compute the new location every tick with the actor’s forward vector. My understanding was that whenever you rotate the actor, you also rotate it’s forward vector, isn’t it ?

True, but you said the mesh rotated but not the movement. But that probably has to do with World Rotation somehow. Set Actor Rotation should give you a new forward direction I would think.

This should do what you want it to do. Moves continuously in one direction until it encounters something, then rotates 180 degrees and moves in that direction. I set it up for begin overlap events, but hits will work just as well if you’ve got collisions set up right.

Wow thanks, It looks close to my own blueprint except I was using Set World Rotation instead of Set Actor Rotation. Not sure I understood the difference between the two functions. If you can bother explain me ?

The target of a set world rotation is SceneComponent rather than Actor, so it will be a mesh or capsule or whatever within your actor, rather than the actor itself. So if you get a reference to self and try to attach that to a set world rotation, it will ask if you want to go through a conversion and then pick a component from your actor on it’s own.

Thanks, it works way better with “Set actor rotation”

Thanks, it works way better with “Set actor rotation”