Announcement

Collapse
No announcement yet.

Align Player to Surface?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    Align Player to Surface?

    Greetings,

    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:


    Click image for larger version

Name:	sonic4.jpg
Views:	1
Size:	79.2 KB
ID:	1137396
    Click image for larger version

Name:	Sonicloop.png
Views:	1
Size:	7.6 KB
ID:	1137397

    #2
    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.

    Comment


      #3
      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.

      Comment


        #4
        Somebody did do this already and had it working very smoothly, but annoyingly I can't find the video now :/

        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.

        Comment


          #5
          Originally posted by Ionsol View Post
          Greetings,

          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:


          [ATTACH=CONFIG]8792[/ATTACH]
          [ATTACH=CONFIG]8793[/ATTACH]
          Welcome to the forums, ionsol 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.
          UE4 Development [VR & AR Forums | VR | AR | Magic Leap]
          Make and Maintain Framerate [ Robo Recall Postmortem]
          Let's Connect [Twitter]

          Comment


            #6
            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!) https://youtu.be/V1D1wloSYWE

            https://gyazo.com/66c070d6f6f58d332c2fcaf3c51386a0 (here is a screenshot of the BP)

            Comment

            Working...
            X