Announcement

Collapse
No announcement yet.

Pawn Rotates when runs into wall problem

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

    Pawn Rotates when runs into wall problem

    I'm just wondering why my pawn is getting rotated when it runs head on into a collision wall. My game is a top down shooter, and the pawn gets rotated 90 degrees to the left or right when it runs into a wall.

    I tried doing a trace infront of the pawn to see if geometry was in the way, and when it was, kill all movement. But this started to feel really clunky and snaggy, even on the most basic of collision boxes.

    How do i stop the pawn from rotating when it hits a wall please?

    Thanks

    #2
    How are you stopping the movement? It could just be that the Pawn is facing a rotation of 0,0,0. Does it face the same direction no matter what four walls of a room it runs into?

    Comment


      #3
      Is your pawn always facing the direction it moves in? This could cause the behaviour you're describing. When you run into a wall, the engine changes/modifies the direction you move in so that you "slide" along the wall. I don't believe this is done on the script side anywhere? Sorry if this was unclear to see what I mean just start play in editor with one of the default template maps and run into the center cube at a slight angle. You'll notice you keep going along the wall until it ends and then move with your normal/old direction again.

      Comment


        #4
        Hi. I've commented out that trace code now, but it worked like this:

        Code:
         if(PlayerInput.aStrafe !=0.0 || PlayerInput.aForward !=0.0)
         {
         moving = true;
        
        //If trace succeeded moving = false;
         }
        
         else
         {
         moving =false;
         }
        
        if(moving)
        {
        GetAxes(CurrentCameraRotation, X, Y, Z);
        
        NewAccel.Z	= 0;
        
        NewAccel = PlayerInput.aForward*X + PlayerInput.aStrafe*Y;
        NewAccel = Pawn.AccelRate * Normal(NewAccel);
        	
        }

        It wouldn't matter so much but I'm rotating the pawn's spine bone to face the direction pressed on the right stick. Sometimes, when the pawn runs into collision I can make the spine face 180 degrees in the opposite direction to the legs which is obviously very wrong!

        When the pawn isn't running into collision i do a check to see if the spine if facing beyond a threshold to the legs rotation, and then simply rotate the pawn and play an animation of the legs turning, - so the legs catch up with the body.


        Unreal Everything:
        When the player isn't touching the right stick the pawn faces the direction it's moving in. When the right stick is touched the spine moves to face the direction pushed. If i run right and even hold right on the right stick into a collision wall, the pawn's legs get pushed to either the left of the right, and then i slide along it. If i can't stop this from happening I guess I'll have to review my "legs catching up to the spine" code.

        Thanks

        Comment


          #5
          So in my update rotation function I've setup 3 key vectors:

          1. The actual Pawn Rotation
          2. The direction being pushed on the left stick
          3. The direction being pushed on the right stick

          I then go through and check whether the pawn is stationary and moving the right stick, running, or running AND moving the right stick.

          Then i just compare dot products to see if the spine has rotated too much and the legs need to animate turning and the pawn needs to rotate to face the direction being pushed on the right stick.

          When the right stick is pushed outside of the forward running direction of the left stick the walk backwards animation kicks in and I tell the pawn to face the opposite direction the left stick is being pushed, like so:

          Code:
          if (Spinerotationvector dot Runningrotationvector <= -0.1 )
          {
            if(bcanrotatelegs)
            {
            Pawn.FaceRotation(RInterpTo(Pawn.Rotation, Rotator(-Pawn.Velocity), DeltaTime, LegsRotationSpeed, true), DeltaTime);
            SetRotation(RInterpTo(Pawn.Rotation, Rotator(-Pawn.Velocity), DeltaTime, LegsRotationSpeed, true));
            }
          }
          Previously, in the running AND rotating brackets, I didn't have a check to see if the spine was facing the opposite direction to the actual pawn direction. But i do now:

          Code:
          if (ActualPawnrotationvector dot Spinerotationvector <= -0.3 )
          {
            if(bcanrotatelegs)
            {
              Pawn.FaceRotation(RInterpTo(Pawn.Rotation, MyRotator, DeltaTime, LegsRotationSpeed, true), DeltaTime);
              SetRotation(RInterpTo(Pawn.Rotation, MyRotator, DeltaTime, LegsRotationSpeed, true));
              }
          }
          but this STILL doesn't rotate the pawn when it's sliding up against a collision wall.

          Any help please?

          Thanks

          Comment

          Working...
          X