How to get the angle of the slope the player is facing?

As U know, when a player stands on a slope, the angle of the slope changes depending on which direction the player is facing:

Facing across the slope - angle is horizontal
Facing directly/up down the slope - angle is the full angle of the slope negative/positive
Facing in between - somewhere between horizontal and full angle

So I tried the following projections to align an arrow, always facing forward of the player, with the slope as the player rotates:

And the pitch is correct (yay!). But the yaw is also slightly modified (red arrow) from the player’s forward vector (green arrow), because yaw changes from being projected onto the slope along with pitch.

So let’s try to plug the player’s yaw directly into the arrow rotation, like the following:

So now yaw is perfect, but at the certain angles the red arrow sticks into the ground (uphill) or points too high (downhill), showing it’s pitch is slightly incorrect because it’s based off of the adjusted yaw (i.e. they are out of sync).

The results are about the same using the ā€˜Get Slope Degree Angles’ node. Actually, it’s bit better though certainly not perfect, and the difference gets worse the steeper the hill is.

So it seems like I can get the correct pitch or yaw, but not both. A lil’ help please? :upside_down_face:

vector

Thank U great one! :innocent: I love the elegance of it, but I’m not sure why it’s not quite working for me.

Arrow

I’m doing a line trace, not using the character component

Sorry, should have made that clear! :wink:

Thank U! But for some reason, it’s giving me the identical result. I’m truly puzzled :crazy_face:

Maybe it’s the unusual steepness of the ramp, or the long length of the arrow that makes the difference clearer?

Arrow2

Ah, see what you mean, this should fix it

Yes, oh wonderful wizard, the pitch is perfect but the yaw (red arrow) is also redirected in the new rotation :innocent:

I’m aiming to keep yaw straight (green arrow).


Arrow3

Lost now, I thought you wanted it level with the ground?..

Absolutely, I really appreciate your input on this. But I’m aiming level with the ground at the same rotation in yaw as the player character.

The thing is, when I use ā€œMake Rotator from ZXā€ and ā€œReflect Vector on Planeā€ the pitch is perfect, but yaw is also affected… which is why the green (forward rotation) and green (reflected rotation) aren’t in line.

If I try to correct this by plugging in the raw yaw directly from the player… yaw is now perfect… but pitch goes out of sync (being based on the adjusted yaw, not the raw yaw), so the arrow/box won’t lie flat along the slope reliably.

What are you using for the green arrow? Controller yaw?

Oui, player control rotation or actor rotation without any dynamic pitch.

Can you show the code for the red and green arrows?

Here it is…

From a higher angle with an orthographic camera, you can see how the adjusted yaw differs more easily:

When the player faces directly up or across the slope, the arrows match exactly in yaw… it’s the in-between rotations where the yaw deviation occurs.

Now works 100%, even with the floor check on the character movement component… U are absolutely phenomenal :pray:

Arrow4

:star2:

It’s often a matter of fiddling around with different combos…

Your first level of ā€˜steep hill telekenesis’ is ready :smiley:

:sweat_smile: There’s a niche indie game title right there… ā€œSteep Hill Telekinesisā€. Imma gonna be a bazillionaire! :dollar::dollar::dollar::dollar::dollar::dollar::dollar::dollar:

Ozzy Man Reviews: Cheese Rolling Contest 2018 - YouTube