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"

Calculating Walk Speed Based On Slope and Direction

So I'm working on movement for my first-person character and I want to slow the player down when travelling up slopes and speed them up when travelling down them.

So far I have discovered that you can get the floor normal from the player character movement component:

alt text

Which is great, however my problem is that I need to somehow take this normal and check it relative to my movement direction/velocity (not my facing direction, due to strafing etc.) so that I can determine if I'm going up or down a slope when i'm moving.

This is where my mathematical knowledge falls short unfortunately, so any help on this would be much appreciated!


Product Version: UE 4.21
slope1.jpg (54.0 kB)
more ▼

asked Jan 04 '19 at 10:04 PM in Blueprint Scripting

avatar image

100 6 14 18

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

1 answer: sort voted first

I think the special sauce you're looking for is the vector dot product. For two normalized vectors, their dot product will be 1 if they point in the exact same direction, -1 if they point in exactly opposite directions, or 0 if they are at a right angle to one another.

This means that surfaceNormal (dot) walkingDirection will return 0 for a flat/horizontal surface, increase toward +1 for when moving downhill, or decrease toward -1 for an incline/uphill.

Given that, I think you're looking for something along these lines:


Blueprint screenshot

more ▼

answered Jan 06 '19 at 05:57 AM

avatar image

51 1 7 7

(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