Announcement

Collapse
No announcement yet.

Pawn Wall walking and directional gravity

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

    Pawn Wall walking and directional gravity

    So I've been trying to do the whole wall walking thing and atm I've got this.
    http://www.youtube.com/watch?v=PQrir9rJqyo

    As you can see the pawn can walk on walls but the problem I'm having at the moment is making the pawn rotate to stand on the floor it is currently walking on. It just looks like its glues to it at the minute. Can I get any help with how I can use the floor vector to set the pawns feet to be on the floor.

    Because if I use this

    Code:
    NewRotation = Rotator(Pawn.Floor);
    NewRotation.Pitch += 16384;
    
    Pawn.SetRotation( NewRotation );
    I get the pawn to have his feet on the floor (all be it with a bit of a collision error but thats a diff story) but I am unable to do any additional rotation such as rotating the pawn in the direction it is moving. So if its running vertically up a wall I want it to face the way its running way.

    Is there a way of rotating the pawn relative to its current orientation? So I can yaw the pawn left and right even when its on a wall.

    #2
    Take the existing rotation, and add/subtract to/from it

    Comment


      #3
      It doesnt work as far as I can tell because of the way the pawns rotated.

      When you are on the floor the Yaw would be the pawns Z axis as shown here


      When you are on a wall the Yaw would be the Y axis

      EDIT: Ignore the fact that hes half burred in the wall (a separate bug)

      I suppose I could hardcode a definite rotation for of the 6 faces of a square room but the idea was just to use the floor normal so that the player can be orientated on any surface whose normal is at any angle.

      Does anyone get what I'm getting at?

      Comment


        #4
        native(229) static final function GetAxes ( rotator A, out vector X, out vector Y, out vector Z );

        Comment


          #5
          Ah I see, so thats how you get the local axis which is great. How do I then rotate my pawn about the local "up" axis?

          Comment


            #6
            Can any body help me with this its driving me mad!!!!!

            All I need is to work out how to spin the player when hes on any surface

            Comment


              #7
              I know what you're getting at, and have written an example of this before - but unfortunately it is not a simple solution at all, it involves vast quantities of vector math to get it working vaguely correctly.

              Comment


                #8
                yeah Ive seen something you posted on another thread and tried to use it but I dont understand it.

                Im not after a quick and easy solution so if you're willing to teach me some vector math (as ive forgotten most of it from a level math) I would be very greatful. Or point me to resource to learn from? Thanks

                Comment


                  #9
                  Apply turning with a quaternion.

                  Code:
                  out_ViewRotation = QuatToRotator( QuatProduct(
                                                        QuatFromAxisAndAngle(Z, UnrRotToRad * out_DeltaRot.Yaw),
                                                        QuatFromRotator(out_ViewRotation)
                                                  ) );
                  //where: out_ViewRotation is the current rotation;
                  //       Z is "up" axis (unit vector) of current rotation;
                  //       out_DeltaRot.Yaw has the desired turning amount.

                  Comment


                    #10
                    I tried messing with Quaternions earlier to no success but I will try your method later when I'm on the desktop. Cheers

                    Comment


                      #11
                      Ok I've tried that and I'm getting the problem I had when I tried using Quaternions before.

                      Heres whats happening, I've made it so it draws a coordinate system showing the axes:
                      http://www.youtube.com/watch?v=pAf0TnWjuSI

                      Code:
                      	function UpdateRotation( float DeltaTime )
                      	{
                      		local Rotator   NewRot, DeltaRot;
                      		local Vector    X, Y, Z;
                      
                      		// this is the base rotation of being on any surface
                      		NewRot = Rotator(Pawn.Floor);
                      		NewRot.Pitch -= DEG90; // aligns the pawns feet to the surface
                      
                      		// get the local axes of the pawn
                      		GetAxes(NewRot, X, Y, Z);
                      
                      		DrawDebugCoordinateSystem(Pawn.Location,  NewRot, 200.0f, false);
                      
                      		DeltaRot = OldDeltaRot; // assign the olddelta rotation
                      
                      		// process mouse input
                      		if(PlayerInput.aMouseX > 0)
                      			DeltaRot.Yaw += 1000;
                      		else if(PlayerInput.aMouseX < 0)
                      			DeltaRot.Yaw -= 1000;
                      		
                      		// THIS DOESN WORK (and I dont understand why as this is what I've used in XNA before)
                      		NewRot = QuatToRotator( QuatProduct(
                                                            QuatFromAxisAndAngle(Z, UnrRotToRad * DeltaRot.Yaw),
                                                            QuatFromRotator(NewRot)
                                                      ) );
                      
                      		Pawn.SetRotation(NewRot);
                      
                      		OldDeltaRot = DeltaRot;
                      	}
                      I'm at a loss here

                      Comment


                        #12
                        It does work (the quaternion stuff); the pawn is rotated around the blue axis.

                        The problem you have is caused by the initial values you give to NewRot, which are wrong.

                        Comment


                          #13
                          But when I remove the additional quaternion stuff like so:
                          Code:
                          	/** This adjusts the pawns rotation so that it stands on the surface it is on */
                          	function UpdateRotation( float DeltaTime )
                          	{
                          		local Rotator   NewRot, DeltaRot;
                          		local Vector    X, Y, Z;
                          
                          		// this is the base rotation of being on any surface
                          		NewRot = Rotator(Pawn.Floor);
                          		NewRot.Pitch -= DEG90; // aligns the pawns feet to the surface
                          
                          		// get the local axes of the pawn
                          		GetAxes(NewRot, X, Y, Z);
                          
                          		DrawDebugCoordinateSystem(Pawn.Location,  NewRot, 200.0f, false);
                          
                          		DeltaRot = OldDeltaRot; // assign the olddelta rotation
                          
                          		// process mouse input
                          		if(PlayerInput.aMouseX > 0)
                          			DeltaRot.Yaw += 1000;
                          		else if(PlayerInput.aMouseX < 0)
                          			DeltaRot.Yaw -= 1000;
                          		
                          		// THIS DOESN WORK (and I dont understand why as this is what I've used in XNA before)
                          		/*NewRot = QuatToRotator( QuatProduct(
                                                                QuatFromAxisAndAngle(Z, UnrRotToRad * DeltaRot.Yaw),
                                                                QuatFromRotator(NewRot)
                                                          ) );*/
                          
                          		Pawn.SetRotation(NewRot);
                          
                          		OldDeltaRot = DeltaRot;
                          	}
                          The pawn orientates to the floor fine, but obviously now I cant do the additional rotation.
                          http://www.youtube.com/watch?v=WPKQoR5XFU8

                          EDIT: WHAT AM I DOING WRONG LOL!

                          Comment


                            #14
                            I guess it's a coincidence. Note that the red and green lines aren't facing the correct directions anyways.

                            You have to get a correct base rotation from floor vector and camera face rotation.

                            Comment


                              #15
                              Well my base rotation is calculated using the floor normal.

                              BaseRot = Rotator(Pawn.Floor);
                              BaseRot.Pitch -= 16384;

                              How does your sonic GDK do it, as I guess you pawn uses the surface normal to orientate itself.

                              Comment

                              Working...
                              X