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:

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!

Thanks.

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: