Behavior Trees Rotate to face BB Entry and MoveTo can never work together reasonably?

I’m a programmer, but I still am having a very difficult time with what should be simple AI behavior. From what I can tell if one wants to use the MoveTo behavior tree node with any sort of smooth rotation it requires setting up the character controller to allow Orientation to Movement with a good rotation rate and NOT allow use controller yaw. However, for the rotation to face BB entry, you must have the settings the exact opposite. Using the AI set focus is an entirely different means of doing things, but none of these things seem to work together and the documentation only demonstrates simplified movements following the player. I just want to turn realistically and run from the player… can’t this be done without creating a complicated codeset? I must be missing something, it can’t possibly be this hard to do something this simple, is it? I would really appreciate some help.

5 Likes

After much research, trial and error it appears that there are several values that need to be set in tandem in order to get this functionality to work. Here’s the steps for anyone else looking into this:

  • Make sure Use Controller Rotation Yaw is disabled on the main component of the AI agent pawn.
  • In the Movement Component of same pawn, set Orient Rotation to Movement disabled, and Use Controller Desired Rotation to enabled.
  • Rotation Rate Z value of the Movement component of the pawn controls rotation speed. This does not take into consideration direction, so if the move to is toward a position behind the agent, the agent will appear to move backward as it rotates until forward motion takes over. Higher Z rotation minimizes the oddness of this transition.
  • Set AI Focus can be done through the AI Controller to get rotation, or the use of the Rotate to face BB entry in behavior tree. For some reason, I have been unable to get the Set Default Focus service in the behavior tree but the Rotate To Face BB Entry works.
  • FYI: Set AI Focus turns the capsule, not the head of the agent. So if you are looking for a more realistic means of using a view cone then you will have to code it from what I can tell. AI Perception also uses the capsule for its view cone setup.

If anyone reading this has found any better methods that above please let me know.

28 Likes

Hi @NawTCar
It working, thank’s. I had correct settings few months ago, but worked on other parts of project than AI and I forgot a lot :slight_smile:
With AI in UE I have problems, not because general rules, but single bad settings check/uncheck can ruin whole work. Not mention lack of documentation about AI and EQS.
Anyway - facing working!

1 Like

Thank you very much for posting the correct solution!

Hi, thanks a lot for posting this! It finally worked! It almost drove me crazy!!!

An addendum: Tick must also be enabled on your AI Controller.

3 Likes

There is also the possibility to have the Controller rotating itself to focus an Actor.

AIController->SetFocus(Target);

You then need at some point to clear the focus.