Announcement

Collapse
No announcement yet.

Walking on a wall

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

    Walking on a wall

    In my game player can walk on walls by holding cpecial button - but it only idea, i don't know how realize it in UnrealScript

    P.S. It TPS Game
    P.P.S. Sorry for my bad english

    #2
    You could literally port over the PHYS_Spider code of UT2003. You only have to comment away the not-compilable lines to make it work, as far as I can remember.

    Comment


      #3
      What is "PHYS_Spyder" - this is mutator/mod or something else? Correct me if I have incorrectly understood you

      Comment


        #4
        PHYS_Spider is one of the basic physics states for actors. You can see them all in the EPhysics declaration in Actor.uc

        There is some basic functionality built in, to let the player 'walk on walls', using PHYS_Spider, but it has never been fully implemented in any of the UT games, so you will have to figure out a lot for yourself.

        Comment


          #5
          So, i think im on right way...
          I find "PHYS_Spider" in actor.uc, but i not completly understand how it use...
          ...In UTGame defafalt mode when player pressing "F", activated PHYS_Falling - i tried to simple replace PHYS_Falling and PHYS_Spider... but fail...

          Comment


            #6
            You would have to use SetPhysics(PHYS_Spider) rather than setting the Physics variable directly... But i'm not sure just setting they physics mode will do much.. There is likely a bit more work that would need to be done before you get something half-ways like you want, and you are unlikely to find any real documentation on what that entails.

            Comment


              #7
              Id love to see someone get this working, seems to come up a couple times a week

              Comment


                #8
                yeah, AvP feeling *g*

                Comment


                  #9
                  I already said how you can get it to work in the second post... You can literally port the UT2003 code, comment away the uncompilable lines and it works. I still have a video of it somewhere proving it really works.



                  Disclaimer: This was a WIP of a mod I was working on, I think it died somewhere down the line for UT3 and I'm not sure what became of it now. Do not ask me about it. Technically I'm not even supposed to show this video.

                  Comment


                    #10
                    This is my version. It has collision issues that I never solved. If you use it, then stick to the condition, and please post here and update it with any fixes you add.

                    Code:
                    state PlayerSpidering
                    {
                    ignores SeePlayer, HearNoise, Bump;
                    
                        event bool NotifyHitWall(vector HitNormal, actor HitActor)
                        {
                            Pawn.SetPhysics(PHYS_Spider);
                            Pawn.SetBase(HitActor, HitNormal);
                            return true;
                        }
                    
                        // if spider mode, update rotation based on floor
                        function UpdateRotation(float DeltaTime)
                        {
                            local rotator ViewRotation;
                            local vector MyFloor, CrossDir, FwdDir, OldFwdDir, OldX, RealFloor;
                    
                            if ( (Pawn.Base == None) || (Pawn.Floor == vect(0,0,0)) )
                                    {
                                MyFloor = vect(0,0,1);
                                    }
                            else
                                    {
                                MyFloor = Pawn.Floor;
                                    }
                            if ( MyFloor != OldFloor )
                            {
                                // smoothly transition between floors
                                RealFloor = MyFloor;
                                MyFloor = Normal(6*DeltaTime * MyFloor + (1 - 6*DeltaTime) * OldFloor);
                    
                                            if ( (RealFloor dot MyFloor) > 0.999 )
                                            {
                                    MyFloor = RealFloor;
                                            }
                                            else
                                            {
                                                    // translate view direction
                                                    CrossDir = Normal(RealFloor Cross OldFloor);
                                                    FwdDir = CrossDir cross MyFloor;
                                                    OldFwdDir = CrossDir cross OldFloor;
                                                    ViewX = MyFloor * (OldFloor dot ViewX) + CrossDir * (CrossDir dot ViewX) + FwdDir * (OldFwdDir dot ViewX);
                                                    ViewX = Normal(ViewX);
                                                    ViewZ = MyFloor * (OldFloor dot ViewZ) + CrossDir * (CrossDir dot ViewZ) + FwdDir * (OldFwdDir dot ViewZ);
                                                    ViewZ = Normal(ViewZ);
                                                    OldFloor = MyFloor;
                                                    ViewY = Normal(MyFloor cross ViewX);
                    
                                                    Pawn.mesh.SetRotation(OrthoRotation(ViewX,ViewY,ViewZ));
                                            }
                            }
                    
                            if ( (PlayerInput.aTurn != 0) || (PlayerInput.aLookUp != 0) )
                            {
                                // adjust Yaw based on aTurn
                                if ( PlayerInput.aTurn != 0 )
                                            {
                                    ViewX = Normal(ViewX + 2 * ViewY * Sin(0.0005*DeltaTime*PlayerInput.aTurn));
                                            }
                    
                                // adjust Pitch based on aLookUp
                                if ( PlayerInput.aLookUp != 0 )
                                {
                                    OldX = ViewX;
                                    ViewX = Normal(ViewX + 2 * ViewZ * Sin(0.0005*DeltaTime*PlayerInput.aLookUp));
                                    ViewZ = Normal(ViewX Cross ViewY);
                    
                                    // bound max pitch
                                    if ( (ViewZ dot MyFloor) < 0.707   )
                                    {
                                        OldX = Normal(OldX - MyFloor * (MyFloor Dot OldX));
                                        if ( (ViewX Dot MyFloor) > 0)
                                                            {
                                            ViewX = Normal(OldX + MyFloor);
                                                            }
                                        else
                                                            {
                                            ViewX = Normal(OldX - MyFloor);
                                                            }
                    
                                        ViewZ = Normal(ViewX cross ViewY);
                                    }
                                }
                    
                                // calculate new Y axis
                                ViewY = Normal(MyFloor cross ViewX);
                            }
                            ViewRotation =  OrthoRotation(ViewX,ViewY,ViewZ);
                            SetRotation(ViewRotation);
                            Pawn.FaceRotation(ViewRotation, deltaTime );
                    
                                    //SET PAWN ROTATION WITH RESPECT TO FLOOR NORMALS HERE
                                    //Pawn.mesh.SkeletalMesh.Rotation = Pawn.Rotation;
                    
                        }
                    
                        function bool NotifyLanded(vector HitNormal, Actor FloorActor)
                        {
                            Pawn.SetPhysics(PHYS_Spider);
                            return bUpdating;
                        }
                    
                        event NotifyPhysicsVolumeChange( PhysicsVolume NewVolume )
                        {
                            if ( NewVolume.bWaterVolume )
                                    {
                                GotoState(Pawn.WaterMovementState);
                                    }
                        }
                    
                        function ProcessMove(float DeltaTime, vector NewAccel, eDoubleClickDir DoubleClickMove, rotator DeltaRot)
                        {
                            if ( Pawn.Acceleration != NewAccel )
                                    {
                                            Pawn.Acceleration = NewAccel;
                                    }
                    
                            if ( bPressedJump )
                                    {
                                Pawn.DoJump(bUpdating);
                                    }
                        }
                    
                        function PlayerMove( float DeltaTime )
                        {
                            local vector NewAccel;
                            local eDoubleClickDir DoubleClickMove;
                            local rotator OldRotation, ViewRotation;
                            local bool  bSaveJump;
                    
                            GroundPitch = 0;
                            ViewRotation = Rotation;
                    
                            //Pawn.CheckBob(DeltaTime,vect(0,0,0));
                    
                            // Update rotation.
                            SetRotation(ViewRotation);
                            OldRotation = Rotation;
                            UpdateRotation(DeltaTime);
                    
                            // Update acceleration.
                            NewAccel = PlayerInput.aForward*Normal(ViewX - OldFloor * (OldFloor Dot ViewX)) + PlayerInput.aStrafe*ViewY;
                    
                                    if ( VSize(NewAccel) < 1.0 )
                                    {
                                NewAccel = vect(0,0,0);
                                    }
                    
                            if ( bPressedJump && Pawn.CannotJumpNow() )
                            {
                                bSaveJump = true;
                                bPressedJump = false;
                            }
                            else
                                bSaveJump = false;
                    
                            ProcessMove(DeltaTime, NewAccel, DoubleClickMove, OldRotation - Rotation);
                            bPressedJump = bSaveJump;
                        }
                    
                        event BeginState(Name PreviousStateName)
                        {
                            //if ( Pawn.Mesh == None )
                            //    Pawn.SetMesh();
                            OldFloor = vect(0,0,1);
                            GetAxes(Rotation,ViewX,ViewY,ViewZ);
                            DoubleClickDir = DCLICK_None;
                            Pawn.ShouldCrouch(false);
                            bPressedJump = false;
                    
                            if (Pawn.Physics != PHYS_Falling)
                                    {
                                Pawn.SetPhysics(PHYS_Spider);
                                    }
                    
                                    GroundPitch = 0;
                            Pawn.bCrawler = true;
                        }
                    
                        event EndState(Name NextStateName)
                        {
                            GroundPitch = 0;
                            if ( Pawn != None )
                            {
                                Pawn.ShouldCrouch(false);
                                Pawn.bCrawler = Pawn.default.bCrawler;
                            }
                        }
                    }

                    Comment


                      #11
                      Code location

                      I'm sorry if this seems like a dumb question to ask, but ambershee, where exactly would I place that code of yours so I can try it out? Any help would be fantastic. Thank you very much.

                      Comment


                        #12
                        It's a movement state for a player controller class.

                        Comment


                          #13
                          I really appreciate you getting back to me on this, especially so quickly. I hate to pester you again, but unfortunately that was just a bit too vague for me (I'm just beginning to figure our how UDK handles is scripts and everything...) could you maybe specify a file name and/or where to place it? Thanks again.

                          Comment


                            #14
                            What he means is you place that in the class you made like myplayercontrollerclass.uc.
                            Create a file and extend off of utplayercontroller and place those states in. Ambershee thats pretty cool reminds me of ratchet and clank

                            Comment


                              #15
                              Originally posted by Gavin.Race View Post
                              I really appreciate you getting back to me on this, especially so quickly. I hate to pester you again, but unfortunately that was just a bit too vague for me (I'm just beginning to figure our how UDK handles is scripts and everything...) could you maybe specify a file name and/or where to place it? Thanks again.
                              Follow some introductory tutorials, work with Unreal a bit and then come back to it - the code itself is reasonably complicated but easy to implement.

                              You don't just drop code into existing files, this is a very wrong approach.

                              Comment

                              Working...
                              X