Hey everyone, got something that’s probably a simple solution but its been giving me trouble for awhile now (who knows, typing this out may help me figure it out:
First off is my earlier thread on the Answer Hub, different issue but it provides more info as to how this is set up:
So currently my AI works pretty well except for one thing, its rotation can jutter, stutter, and jump. To fix this I used RInterp to set the Actor’s rotation to face the player using Find Look At Rotation. This somewhat worked, but it never quite did it.
The main issue though, is the AI will not turn to face the player if the player can get behind it.
My gut tells me this is more to do with the Behavior Tree, as it will face the player once they leave the “acceptable distance” of attacking (300 units between the AI and the player).
But I also don’t know if this has to do with its rotation, as it will rotate to the player if I set the interp speed to something ridiculous. At 3 or 5 though it very, very slowly turns to the player. Not smoothly, mind you.
Anyway, pictures are way more help than words so:
First, we have the Behavior Tree service, Data Check. This runs each tick and sets a bunch of values the AI uses. One of these is the AI’s rotation as seen :
It switches between using the Controller Focus node and the Set AI Rotation Interface as Focus is the only one to give smooth movement during strafing behavior (as talked about in the Answer Hub post).
Yes, its hacky and I’m trying to find a better solution.
Next, we have the rotation function itself inside the AI actor’s event graph:
Setting Current Rotation again rather than passing the value through is probably unnecessary, but anyway.
Next we have what the issue looks like inside the editor:
Now while behind the AI, the rotation will either not work or move so slow as to not be working at all. The AI will continue to swing at air as long as I stand right . If I leave its acceptable radius and it needs to get into range again by moving it will rotate towards me.
But while standing there, nada.
One last thing, I decided to set up a key for if the AI is facing the player or not. If not, it can’t attack. To test this I went and stood directly in front of the AI.
Well…
So now it never attacks even when facing the player directly.
Scoured over other threads trying to find something similar but I think this might be unique to me and lies more in the Behavior Tree than the RInterp node. Or in one of the images I’m using incorrect logic and need a nice smack on the head to set me straight.
Or code goblins are changing my values when I’m asleep, who knows.
In Summary:
- The AI does not rotate smoothly using RInterp.
- The AI does not rotate to face the player if the player is behind the AI and within its Acceptable Distance/Radius of 300 units (From the AI to the player).
- If the player leaves this distance/radius, the AI will move towards them and end up rotating to face them.
- The function in the Behavior Tree Service shows that with the way I have it set up, the AI never sets “Facing Player” as true when the player is in front of the AI.
- I’m probably doing something obviously stupid in the above images, please let me know if so.
Other additional info that may help:
Orient Rotation To Movement: Set as True
Use Controller Rotation Yaw: Set as False unless Strafing.
Thanks in advance for any help!