AI SetFocus Instantly snap rotate to location (How to make it rotate smoothly?)

When I Set New Focus, the AI Instantly snap rotate to the focused location… Any Idea how to make it smoothly rotate to the new focused location?

Thank you in advance.

There is no built-in smooth rotation (not in the same way as SetFocus is working), but it’s not complex to implement:

  • Instead of Set Focus, just save the target location in a variable
  • In a tick, calculate the desired rotation from your location and target location
  • use the RInterpTo node for smooth rotation

Here is the good video about how to use this node: WTF Is? Interpolation - RInterp Node in Unreal Engine 4 - YouTube

The problem of not using SetFocus is that (And maybe I’m wrong, except for the last reason which I’ve tested a lot):

  • It’s not heavy on the system as
    RInterpTo that runs every tick.
  • It have better syncing with multiplayer as it’s independent from
    frame tick.
  • With SetFocus AI’s pawn always face the target while it’s moving, which
    uses the Movement Blendspace
    Animations that is based on Direction in the right way. Ex: with SetFocus AI
    will face player and move backward
    normally with the right backward animation,
    while with RInterp the AI will always play “forward”
    animation even if it’s moving backward

I’m thinking though of using RInterpTo/Ease before setting a new focus as a workaround, so for example when player shoot AI from behind the AI will first RInterp smoothly to player over Timeline, then after Timeline finishes I’ll set the new focus… I’m open for suggestions though if there is a better solution :slight_smile:

SetFocus is also use per-tick updates for tracking. Though not sure about network solution, it still should work with manual rotation.

You can use SetFocus along with lerping target location if you want to (just update the focus per tick), but probably it will be heavier than setting manual rotation.

Another workaround is to make an invisible Actor for targeting, call SetFocus to this actor just once, and update it’s location smoothly as you want to.