Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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.

Product Version: UE 4.18
more ▼

asked Dec 28 '17 at 04:08 AM in Blueprint Scripting

avatar image

Sullivan Baker
1 1 1 2

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first


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.

alt text

Hope this helps.

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

more ▼

answered Dec 28 '17 at 04:26 AM

avatar image

1.5k 10 10 18

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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.

more ▼

answered Mar 25 '19 at 09:04 PM

avatar image

187 10 26 25

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question