How to get angle at which player is facing?

My player is an FPS controller. When the player left clicks and is close enough to the surface that they are facing, they should launch in the opposite direction of where they are facing (ex. they face straight down at the floor so they launch straight up). Currently, the player can left click from anywhere and only goes straight up.

Hi,

You can do this with a line trace. First, get actor’s rotation and then it’s forward X vector to determine the direction of Line Trace. Break the Hit result and on a successful hit, the Impact normal will give you the normal vector of the surface. You can then find the angle between your actors forward X vector and this normal by taking the ArcCos of the dot product between these two vectors. The following picture shows its implementation in the Character’s blueprint.

Hope this helps.

–
Please don’t forget to rate this answer if it helped in resolving your issue. Thanks.

1 Like

Presumably there is a First Person Player Camera?

Get the forward vector to see the direction the player is looking (it’s a unit vector with magnitude 1.0f), multiply the vector by -1 to get the unit vector of your impulse (to launch them) and then scale the inverted forward vector by the magnitude of your launch.