So basically, I want to find out if the player is looking at the AI’s face, to trigger a custom event.
Hey, you could try to use “GetPlayerViewPoint” from Player controller, it will return location & rotation of camera, lets call them CamLoc and CamRot. From this, you can do a trace starting from CamLoc, ending at CamLoc + CamRot(transformed to vector → you can use “GetForwardVector”) * Length(should be a float).
Out of this trace, you can check if the hit bone is the head, hope this helps
Yes no problem :
To find the correct bone (here it’s “head”), you can look at the skeletal mesh skeleton tree :
Hi im kinda a newbie, could you send me some screenshots?
thanks.
Hey, thank you very much, I now tried it out, but it’s not working, I do not get any errors, but my custom event does not start when I’m looking at his head (spine_006)
maybe I should use player character instead of player controller?
Basically, I got it working, the only problem is, I need to look at his face exactly to make the event execute, if I look slightly up, it doesn’t work.
Are you seeing the trace starting from your camera and going where you look at? You can set “DrawDebugType” to “ForDuration” on LineTrace node.
If yes then the issue could come from the Physic Asset of your AI’s mesh, check if there is a collision mesh on the bone you are trying to look at. You can check this by clicking on “Physics”, at the top right on my 2nd screen
And it should work if you call the function on PlayerController, you can just “Get” the PlayerCameraManager without casting to PlayerController
You can try to place a SphereCollisionComponent at the location of the AI’s head, then make this sphere respond to a custom TraceChannel (You can create a new TraceChannel in ProjectSettings->Collision->TraceChannels), then modify the TraceChannel of the LineTrace to the new one