Download

AI struggles to "Rotate to Face Enemy" while "Enemy/Player character" is moving (hearing sense)

Hello there. I have an issue on my unreal engine 4 project. I’ve created an enemy AI that can sense the player character by both sight and hearing. I used rotate to face enemy on BT , then disabled “Use Controller Rotation Yaw”, enabled “UseControllerDesiredRotation” and changed the rotation rate for Z. Now the AI rotates smoothly to face the player character when it sees, or hears him once. When I am out of its sight and I don’t stop moving however, It struggles to rotate to the character for as long as it hears the sound(if I stop moving it rotates normally). Any ideas on what may be causing that? PS by struggles I mean that it rotates by a couple of degrees, stops, rotates a bit again and so on.

Hi, I suggest you do some prints in your AI controller and watch the values of the behavior tree while the AI is running to see what is going on.

If the target object to rotate to would always be invalid, it would not rotate at all. If it always would be valid and the same, then it would smoothly rotate to face that object.

Also keep in mind that the perception component fires updates per sense. So every time the AI hears something it will again fire a successfully sensed update and if the latest hearing stimuli reached its age limit, then it will fire a not succsessfully sensed update even if the enemy/player target is still plain in sight (naturally that also works vice versa, so if the a perceived actor runs out of sight it will fire a not successfully sensed update even if that actor is still actively perceived by another sense like hearing).