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:

1 Like

vector

2 Likes

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

1 Like

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

Sorry, should have made that clear! :wink:

1 Like

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

1 Like

Ah, see what you mean, this should fix it

1 Like

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

1 Like

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

1 Like

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.

1 Like

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

1 Like

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

1 Like

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

1 Like

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.

1 Like

1 Like

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

Arrow4

1 Like

:star2:

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

1 Like

Your first level of ‘steep hill telekenesis’ is ready :smiley:

1 Like

: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

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.