Announcement

Collapse
No announcement yet.

Keep Character running forward when colliding with wall

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

    Keep Character running forward when colliding with wall

    Hi I posted this in blueprint scripting but after getting a response thought it might apply more to animation.

    When running into a wall, my character will stop all velocity and start sliding along the wall. This looks and feels extremely clunky (small collisions will jam my character's momentum and turn him).

    I was wondering how I could change my setup so that the character will keep facing the forward direction and keep playing the running forward animation when colliding with a wall (attached picture to better explain this).

    My movement is capsule based and uses a locomotion blendspace that relies on character speed, it seems like I'll have to make it instead rely on gamepad input? I can visualize how this would work, but I would also like to stop rotating my pawn's forward vector when I'm running into a wall.
    Attached Files

    #2
    In short, using the dafualt setups you can't.
    the speed is usually taken from the simulated capsule movement and passed into the pipeline for an animation blendspace to use.
    to change this, would mean changing the way that speed is changed.

    To change this sliding behavour, I would suggest you just align the capsule rotation square to the wall normal you collided on.
    it will prevent people from ever being able to slide since every time the collision occurs the rotation is changed.

    Comment


      #3
      Here is a way to make it work.

      In character BP, use a linetrace to see if something is in front of you and to get the angle of impact (here you can chose against what type of stuff you want the have this behaviour):

      Click image for larger version  Name:	1.jpg Views:	0 Size:	166.4 KB ID:	1780509

      This is can easily be optimized, to prevent a linetrace at every tick. For example, using a box trigger in front of the character to trigger the linetrace only when needed.


      Also in the char BP, to stop running when no pressing "move forward":

      Click image for larger version  Name:	2.jpg Views:	0 Size:	77.4 KB ID:	1780510


      In the animation BP, you check whether or not the char is hitting, and if so, set the velocity directly, else, set as usual:

      Click image for larger version  Name:	3.jpg Views:	0 Size:	180.2 KB ID:	1780511
      Last edited by EvilCleric; 06-25-2020, 04:22 AM.
      "I have harnessed the shadows that stride from world to world to sow death and madness."

      Comment


        #4
        Ty for your responses, I will try these solutions but I'm not sure it's what I'm actually looking for.
        Originally posted by MostHost LA View Post
        In short, using the dafualt setups you can't.
        the speed is usually taken from the simulated capsule movement and passed into the pipeline for an animation blendspace to use.
        to change this, would mean changing the way that speed is changed.

        To change this sliding behavour, I would suggest you just align the capsule rotation square to the wall normal you collided on.
        it will prevent people from ever being able to slide since every time the collision occurs the rotation is changed.
        With the sliding behavior I don't actually want to lock the capsule rotation towards the wall normal, I just want to keep the player's forward trajectory matched with the movement input trajectory.
        Originally posted by EvilCleric View Post
        Here is a way to make it work.

        In character BP, use a linetrace to see if something is in front of you and to get the angle of impact (here you can chose against what type of stuff you want the have this behaviour):

        Click image for larger version Name:	1.jpg Views:	0 Size:	166.4 KB ID:	1780509

        This is can easily be optimized, to prevent a linetrace at every tick. For example, using a box trigger in front of the character to trigger the linetrace only when needed.


        Also in the char BP, to stop running when no pressing "move forward":

        Click image for larger version Name:	2.jpg Views:	0 Size:	77.4 KB ID:	1780510


        In the animation BP, you check whether or not the char is hitting, and if so, set the velocity directly, else, set as usual:

        Click image for larger version Name:	3.jpg Views:	0 Size:	180.2 KB ID:	1780511
        I tried this solution but this was not reliable at all, there was no real change except for when the character lined up perfectly with the collision object and the speed would spike up to the set value.

        I've made a few gifs that show exactly what I'm looking at, about half of my static meshes actually allow me to move the character like I was hoping, but half of my meshes make my pawn get stuck.

        Gif 1 shows the exact behavior I want (keep forward velocity, doesn't rotate the pawn and screw up movement input).
        Gif 2 shows my character stuck (what I'm trying to eliminate because this behavior feels awful in playtesting).
        Gif 3 shows the behavior I want again, but my character gets stuck in the little crevasse (trying to eliminate that).

        (Sorry for the gif quality, had to reduce it a ton to upload).
        Attached Files

        Comment


          #5
          Originally posted by AyyKenny View Post
          the speed would spike up to the set value.
          I thought you wanted to keep running at the same speed? I set the speed in the animation BP to 600. Your case, maybe is lesser. That's why the spike.
          "I have harnessed the shadows that stride from world to world to sow death and madness."

          Comment


            #6
            Is Gif 1exactly what you want? Because that's exactly what happens with my solution.
            Last edited by EvilCleric; 06-25-2020, 03:27 PM.
            "I have harnessed the shadows that stride from world to world to sow death and madness."

            Comment


              #7
              Originally posted by EvilCleric View Post
              Is Gif 1exactly what you want? Because that's exactly what happens with my solution.
              Your solution does work really well, when I hit collision exactly perpendicular to the wall the velocity takes over and it works perfectly, but when the normal force starts rotating my character the collision check turns false... maybe I can figure out how to implement MostHostLA's idea and keep the capsule rotated towards the movement input?

              Edit: Gif 2 is still a problem with your solution, but you've definitely put me a step in the right direction so TY
              Last edited by AyyKenny; 06-25-2020, 04:14 PM.

              Comment


                #8
                Originally posted by AyyKenny View Post

                Your solution does work really well, when I hit collision exactly perpendicular to the wall the velocity takes over and it works perfectly, but when the normal force starts rotating my character the collision check turns false... maybe I can figure out how to implement MostHostLA's idea and keep the capsule rotated towards the movement input?
                This is going to be my last attempt. With some extra nodes, the character keeps its original impact orientation (the normal force that rotates the character is eliminated) and also allows you to move left and right without rotating the character. At least until no more impact or you stop pressing forward.

                Detect impact, save the present rotation, and while "impact" keep same rotation

                Click image for larger version  Name:	1.jpg Views:	0 Size:	248.1 KB ID:	1780852
                "I have harnessed the shadows that stride from world to world to sow death and madness."

                Comment


                  #9
                  Originally posted by EvilCleric View Post

                  This is going to be my last attempt. With some extra nodes, the character keeps its original impact orientation (the normal force that rotates the character is eliminated) and also allows you to move left and right without rotating the character. At least until no more impact or you stop pressing forward.

                  Detect impact, save the present rotation, and while "impact" keep same rotation

                  Click image for larger version Name:	1.jpg Views:	0 Size:	248.1 KB ID:	1780852
                  This just locks the rotation to whatever the impact is, which isn't really what I'm looking for. But it also doesn't fix the problem I have in gif 2. There must be something different with the collision impact on the meshes in gif 2.

                  I really appreciate your help and you've given me some good ideas to play with, thanks.



                  Update: I figured out a solution to combine with what EvilCleric created, I changed my calculate direction in my ABP to use last movement input rather than velocity. I also changed the line trace to a sphere trace and removed the forward impact check (was ignoring getting stuck in corners). Lastly I had some weird rotation stuff going on to smoothly rotate my char during weapon swings so I took that out and will probably have to rework it. Hopefully these fixes won't break other things, but it looks smooth now. TY for the help guys.


                  Attached Files
                  Last edited by AyyKenny; 06-25-2020, 07:47 PM.

                  Comment


                    #10
                    I would suggest a sphiel like the capsule component or even just hooking it directly to the capsule component...
                    not that it really matters anyway. You wouldn't get a performance hit unlrss you check continuous detection and constant overlaps.

                    Comment

                    Working...
                    X