I’m building an AI for my character to face me whenever I enter a trigger box. However, I noticed that it looks unnatural as it sort of glides around to face me. I want the NPC to stand still, but move it’s head according to the camera.
Here is my blueprint so far. If I need to do anything else, please let me know. I appreciate the help!
You’ll probably have to add a bit more to the Pawn class. Like a function to rotate head and then pass this rotation on to the pawn’s skeletal mesh component.
Just a guess. I’m unexperienced myself : P.
You will need to have the head on a socket or the neck bone
Basically you want to rotate the bone that the head is attached to of the skeletal mesh
I haven’t tried to do this but the other possible option is to remove the head and reattach it using a socket and then rotate that
What you are doing right now is moving the complete character
Best way to achieve this is to find the world location you want your AI to look at then pass it to its AnimGraph Blueprint and use the LookAt function as seen in the screen below.
Hope it helps
Sorry for the delayed response. This almost works! It’s looking, but I’m not sure how to set the “Look at World Location” or “Look at Alpha” to the player character. Also, if the player is behind the NPC, I don’t want its head to look straight out of a horror movie. Please advise. Thanks again! I genuinely appreciate it.
Update: I just set the “Look at world location” to get player character → get actor location so that it can track my character. However, I’m not sure what to do for the alpha value…Please advise!
UPDATE: It works! I had to scrap the blueprint and make a new set, but it’s functional and so I want to thank everyone for their help!
The alpha value can be used to interpolate between head direction from animation and head direction from LookAt node. Usually setting it to 0.9 or 1 is enough to get something smooth but you can achieve a better effect by branching it to a non linear timeline curve in you character eventgraph.