Slope Orientation Issues

Alright, so I’m programming a custom character script, so your character can go up and down walls, and whatever terrain. And it works for the most part, but there’s a small issue.

I keep the character’s current Y rotation in a variable, and this is typically correct on flat ground, but lets say you’re on a wall. So on flat ground it points on the -Z axis. But lets say you were on a 90 degree wall to the side, it points in the -Z axis and stays aligned with the ground by tilting the player 90 degrees on the X axis, but if you were on a wall that was behind the player, it would have to be aligned with the ground by tilting the player 90 degrees on the Z axis, so if you went between these 2 walls, your player would turn in an undesirable way.

Tl;dr: The character is changing direction when the wall’s rotation changes.

I’ve tried tons of things. Comparing specific cross products, specific dot products, seeing how the character’s global Y axis rotation changes, but none if it gives a really consistent result. Could you help?

2 Likes

The issue is that you’re storing the Y rotation in world space coordinates, but what you really care about is the rotation compared to what is currently the ground. Getting a custom character to work in every situation can be pretty involved.

You might want to have a look at this, it’s basically what you’re trying to create. You can use it, or see how EgoMoose did it when making your own.

I’ll take a look at it tomorrow morning

Hm, doesn’t look like this will help, since it’s a completely different concept with “Fake worlds” and stuff.