Align Player to Surface?


I’m wondering how I might go about creating a blueprint that forces a player to always stay aligned to a surface such as while running around a loopdeloop or helix like in Sonic the Hedgehog:


Do a line trace from the characters feet downwards, return the surface normal and rotate your character accordingly.

If you want to do that with the default Character Pawn, it’ll require C++ though. Could also try changing the “Walkable Slope Z” value and see if that works, though I suspect gravity will just yank you back down.

I’ve had limited luck doing a trace “down” (not Z down, but from character core outward in the direction of the bottom of the capsule, in case we’re already rotated) and applying character rotation, and temporarily adjusting both the Walkable Slope height (so the player can move across the surface) and Max Step Height (so the player can stand on it without being pulled down)

It only works for slopes that get to about 80°. The player cannot move freely across vertical walls or upside-down (though someone in these forums is implementing such functionality, it’s quite tough since Unreal in many cases has Z hard-coded to Up), but for my purposes, which is rapidly dashing around steep bank curves, it works well.

All of which I guess is to say that what you can do will depend on the reason you’re trying to rotate your player to a surface.

Somebody did do this already and had it working very smoothly, but annoyingly I can’t find the video now :confused:

As your running on the inside of a loop and not outside of it, you could perhaps do two traces and average them out, and use that to rotate the character in advance before the next step. Make that trace follow the velocity slightly and clamp it so it doesn’t go crazy, then average out the impact points and normals. This might make the movement a bit smoother if you’re having issues, effectively pre-emptively determining what orientation the player should have next frame.

Welcome to the forums, ionsol :slight_smile: The line trace method should work for rotation, just adjust it based on the normal of the hit surface, but to RhythmScript’s and TheJamsh’s points, the answer to the question depends much more on what you are trying to accomplish. For instance…

In the Sonic example, two other large factors will be at play when approaching this issue: Gravity and Input.

are you after something like this? its not the best method but it works (for me only whilst in a trigger but you can have it anywhere if you need!)

Screenshot - 66c070d6f6f58d332c2fcaf3c51386a0 - Gyazo (here is a screenshot of the BP)

Thank you classyham