Hello, I’m facing a rather strange issue: The AI Perception Component on my character is not rotating as the character rotates. Here is a screenshot describing the issue:
While the AI Character (Center) is facing the player (Lower left), the AI Perception component points straight and not in the directon the AI Character is looking.
I’ve initialized these values in C++ and created blueprints to place in the world.
Here is the C++ AIPatrol Character Constructor Code
I’ve spent the last 2 days trying to find out what’s going wrong without finding any solutions whatsoever.
Any help to resolve this issue would be greatly appreciated.
Thank You!
Calling RegisterPerceptionStimuliSource is unnecessary if any of the senses used is configured to register always Pawns as sources (and sight is configured like that by default). Also RegisterPerceptionStimuliSource has nothing to do with the described issue.
It’s a strange one. It seems that the relevant AI perception code is being called, since both location and rotation of perception listeners are being updated in one function call. This suggests that your AI’s Rotation is different from its skel mesh’s facing. Have you tried removing bit by bit the changes to the default behavior your code introduces, like the stuff in your AAIPatrol constructor?
The perception component calls the GetActorEyesViewPoint() to get the rotation and the view of the eyes/head, if you don’t override this function in your AICharacter it will use the default one.
In this default one it will call GetControlRotation() I believe, like XanderWraik mentioned.
Try to override this function and set the rotation to the rotation of the mesh or something.
In MyAICharacter.h: