360° Character Movement: What is happening here?

So the idea is to let the character stick to any surface. Upside down or sideways, you name it.

And it works… in theory.
So if I place the character near a surface, it sticks to it no problem:

Example 1

However, if it is possessed, the rotation freaks the hell out when crossing 90°:

Example 2

(you can still see the uncontrolled character idling up there)

The method is pretty simple, a line trace gets the normal of the surface, adjusts the rotation accordingly and then adds force to the character movement component towards the surface.

I have seen similar topics already, where people ask how to do it, usually answered by other people saying it’s hard to do and not explaining why it would be so hard.

So, my question is, why does it work when the pawn is not controlled but doesn’t work if it’s possessed?

(to clarify, the character also freaks out if it’s being possessed while already sitting at an angle >= 90°)

Any ideas are appreciated.

(also here is the blueprint script responsible for keeping the character on the surface: https://blueprintue.com/blueprint/h7iy-95r/, I don’t really see why it is freaking out like that)

EDIT: Nevermind, I think I’ve got the answer. The freaking out has probably to do with gimbal lock.

So when yaw and pitch align it messes up the whole rotation. Will provide the full explanation when I found a clean way to fix it.

1 Like

So, for the sake of completion, here is the answer:

If you want to let your character walk on surfaces that are angled at more than 90°, don’t use the control rotation UE4 provides. Not for rotating the character, nor for rotating the spring arm (nor for anything else). It can’t handle that kind of movement. You also can’t rely on euler rotation.

The principle of getting a character sticking to the surface stays the same though, just make sure to consistently use quaternion instead of the euler rotation.
Line tracing down relative to the character rotation to get the surface normal, then rotating the character based on the result.
Lastly you want to add force to the character movement component to simulate gravity.
Then you will have to make a quaternion based camera control and with that set up you can also make a new control rotation.

If you want to do this in blueprints, you probably want this:

Blueprint Quaternion Library

1 Like