Announcement

Collapse
No announcement yet.

Ledge Grabing, Wall climbing and Wall running

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

    #31
    well first off, you made your bind to call the function Climb()
    but your trace is in a function called Use(), not climb.

    This would be why it's not working.

    you either need to:

    A) change your function to the following:
    Code:
    exec function Climb()
    {
    //    etc...
    }
    or

    B) change your binding to match the function
    Code:
    Bindings=(Name="GBA_Climb",Command="Use")
    .Bindings=(Name="W",Command="GBA_Climb")
    the "Command= " denotes the name of the function you're trying to call.

    Also, you should be careful, I think binding this to "W" will call your function repeatedly when the key is held down which will spam your traces.
    if you want to do it this way you should add a conditional so it only traces if you're sure there's an object in front of you.

    Comment


      #32
      is it because W is a directional key? I'm doing a 2D Platformer so basically I use A and D to move . I changed for E and changed the command to Use(). I also properly verified that I'm using a static mesh. But I got no way to know if the trace is working. Am I missing something?

      Comment


        #33
        Yes, you are correct. I was assuming you were still using "W" for forward movement. In this case, you can ignore my previous statement.

        Also, there are two ways to know if your trace is working.
        The first being the DrawDebugLine(StartTrace, EndTrace,255,0,255,true);
        This should draw a line representing the trace while you're playing.

        Also, if your trace hits a staticmeshactor there should be no reason for it not to play the animation that I can see (as long as your pawn is within the 45 unit trace distance).

        Comment


          #34
          Thanks .Wrath
          Is the trace line supposed to be visible? because for me it isn't.
          I tried everything but still not working.

          I thought perhaps it was due to the fact that I was using a 2D camera and that maybe the tracing was being done in another direction. Changed my code back to first person but
          still nothing.
          I'll continue trying to figure out why is not working and I'll post more questions later.

          Thanks again!

          Comment


            #35
            it's not working & you can't see it because you have a mistake when you assign your StartTrace vector, here:

            Code:
            	StartTrace = HitLocation + (Dir * TraceAdd);
            	
            	EndTrace = StartTrace + (Dir * TraceDist);
            	
            	TraceHit = Trace(HitLocation, HitNormal, StartTrace, EndTrace, true);
            	DrawDebugLine(StartTrace, EndTrace,255,0,255,true);
            You're using HitLocation which hasn't been found yet, so it's most likely giving you [ vector(0,0,0) + (Dir * TraceAdd) ] as the start point of your trace.
            you need to change HitLocation to ANPawn(Pawn).Location so it knows to start from your controller's pawn's location.

            Comment


              #36
              .Wrath, thanks again!

              I changed the HitLocation in:

              Code:
              StartTrace = ANPawn(Pawn).Location + (Dir * TraceAdd);
              Also played around with adding

              Dir.Z =
              Which if I properly understood, allows me to do a trace in another direction.

              So far my code
              Code:
              exec function Use()
              {
              	local Actor  TraceHit;
              	local vector HitLocation, HitNormal, StartTrace, EndTrace, Dir;
              	local float  TraceDist, TraceAdd;
              	
              	
              
              	TraceAdd  =  5;
              	TraceDist = 45;
              	Dir = vector(Rotation);
              	StartTrace = ANPawn(Pawn).Location + (Dir * TraceAdd);
              	StartTrace.Z = 90;
              	
              	EndTrace = StartTrace + (Dir * TraceDist);
              	
              	TraceHit = Trace(HitLocation, HitNormal, StartTrace, EndTrace, true);
              	DrawDebugLine(StartTrace, EndTrace,255,0,255,true);
              
              			
              			if (TraceHit == none)
              			{
              				return;
              			}
              											
              			 if(TraceHit.IsA('StaticMeshActor'))
              				 {
              					 GotoState('Climb');
              					 ANPawn(Pawn).SetPhysics(PHYS_Flying);
              					 ANPawn(Pawn).FullBodyAnimSlot.PlayCustomAnim('Climb', 0.5, 0.1, 0.1, FALSE, TRUE);
              				 }
              				 else
              					{
              					GotoState('Jump_Fall');
              					ANPawn(Pawn).SetPhysics(PHYS_Falling);
              					ANPawn(Pawn).FullBodyAnimSlot.PlayCustomAnim('Jump_Fall', 0.5, 0.1, 0.1, FALSE, TRUE);
              					}
              
              	}
              I added the state Jump_Fall but is not being recognized. My character continues moving forever.
              Do I have to create another state for the Falling state?

              I still don't understand how to make it so after the character climbs, he goes to PHYS_Walking or if the key is no longer pressed, he falls
              I added in the DefaultInput.ini the OnStop but without results.

              Also I was wondering, concerning the wall running: Could this be done by doing a trace to a material rather than a Static mesh? In that case, it would depend
              on the key input the actions the character would do.

              Thanks again for your help!

              Comment


                #37
                Even after changing GoToState('Jump_Fall') to:

                Code:
                 GoToState('PlayerWalking');
                		 ANPawn(Pawn).SetPhysics(PHYS_Walking);
                		 ANPawn(Pawn).FullBodyAnimSlot.PlayCustomAnim('Idle', 0.5, 0.1, 0.1, FALSE, TRUE);
                Still no working. I tried several things but no luck.
                My other problem is that the trace is done to the four directions and my game is a platformer so I wanted to be only in the direction the character is facing.
                Played with Dir.Y = 90 and my trace was done in the right direction but would pass through the Static meshes and was too far away from the character.

                Any ideas?
                Thanks in advance!

                Comment


                  #38
                  How do I set the trace Dir in only one direction?
                  Code:
                  Dir = vector(Rotation);
                  is there any way to lock the rotation to the Z axis only?
                  and set it to be at a certain angle from the BaseEyeHeight?
                  Let's say, from the character's point of view 45 degs. up to a ledge.

                  Also I still have the problem of the animation playing forever.

                  Thanks in advance!

                  (This is almost a shameless bump but I really need help with this)

                  Comment


                    #39
                    So, I assume you fixed your bind since your animation is playing, so that's good.

                    I see you're still trying to handle this through states... Have you seen this UDN page?

                    Originally posted by FraktalZero View Post
                    Even after changing GoToState('Jump_Fall') to:

                    Code:
                     GoToState('PlayerWalking');
                    		 ANPawn(Pawn).SetPhysics(PHYS_Walking);
                    		 ANPawn(Pawn).FullBodyAnimSlot.PlayCustomAnim('Idle', 0.5, 0.1, 0.1, FALSE, TRUE);
                    Still no working. I tried several things but no luck.
                    My other problem is that the trace is done to the four directions and my game is a platformer so I wanted to be only in the direction the character is facing.
                    Played with Dir.Y = 90 and my trace was done in the right direction but would pass through the Static meshes and was too far away from the character.

                    Any ideas?
                    Thanks in advance!
                    I have no idea what you mean by "the trace is done to the four directions" ....dir represents your pawns rotation in vector form (since that's what we set it to) and vectors only have 3 axes
                    If you change it then it won't work properly, since later on you're finding your start and end vectors by multiplying dir by a magnitude.

                    If you give dir.y a value of 90 and then multiply that by 5 (your TraceAdd value) then your trace will end up 450 units away from your pawn in the y direction. When altering this value you need to keep that in mind and make small adjustments as they will compound quickly. On the contrary though, the way you altered StartTrace.Z = 90 is fine, since your not multiplying it by anything it simply moves the Z value of the vector upwards to the new location.

                    If you want to throw a separate trace after the first that would be fine...Something like this...

                    Code:
                    exec function Use()
                    {
                    	local Actor  TraceHit, SecondaryHit;
                    	local vector HitLocation, HitNormal, StartTrace, EndTrace, Dir;
                    	local float  TraceDist, TraceAdd;
                    	
                    	
                    
                    	TraceAdd  =  5;
                    	TraceDist = 45;
                    	Dir = vector(Rotation);
                    	StartTrace = ANPawn(Pawn).Location + (Dir * TraceAdd);
                    	StartTrace.Z = 90;
                    	
                    	EndTrace = StartTrace + (Dir * TraceDist);
                    	
                    	TraceHit = Trace(HitLocation, HitNormal, StartTrace, EndTrace, true);
                    	DrawDebugLine(StartTrace, EndTrace,255,0,255,true);
                    		
                    	if (TraceHit == none)
                    	{
                    		return;
                    	}
                    											
                    	 if(TraceHit.IsA('StaticMeshActor'))
                    	 {
                    		//change the dir
                            Dir.Y = 0.0;  
                            Dir.X = 1.0;  
                            Dir.Z = 0.5;  
                              
                            //Re-Calc StartTrace with the new Dir
                    	    StartTrace = ANPawn(Pawn).Location + (Dir * TraceAdd);
                    	    //Set the height again
                            StartTrace.Z = 90;
                            //Re-Calc EndTrace off the new StartTrace
                    	    EndTrace = StartTrace + (Dir * TraceDist);        
                            //Throw the second trace
                            SecondaryHit = Trace(HitLocation, HitNormal, StartTrace, EndTrace, true);        
                            
                            //if the second trace hit the same thing as the first one...			  
                             if( SecondaryHit == TraceHit )
                    	     {                     
                                  GotoState('Climb');
                    			  ANPawn(Pawn).SetPhysics(PHYS_Flying);
                    			  ANPawn(Pawn).FullBodyAnimSlot.PlayCustomAnim('Climb', 0.5, 0.1, 0.1, false, true);
                             }
                    	 }
                    	 else
                    	 {
                    			  GotoState('Jump_Fall');
                    			  ANPawn(Pawn).SetPhysics(PHYS_Falling);
                    			  ANPawn(Pawn).FullBodyAnimSlot.PlayCustomAnim('Jump_Fall', 0.5, 0.1, 0.1, FALSE, TRUE);
                    	 }	 
                    }
                    Originally posted by FraktalZero View Post
                    How do I set the trace Dir in only one direction?
                    like in the above example. Dir is a vector representing a rotation. but that's only b/c that's what we set it at. like any other vector you can set the individual values of the X, Y, Z axes...but you should be gentle :P

                    Originally posted by FraktalZero View Post
                    Also I still have the problem of the animation playing forever.
                    you can stop the custom anim at any time using

                    Code:
                    FullBodyAnimSlot.StopCustomAnim(float BlendOutTime);
                    I think you could also use:
                    Code:
                    /**
                     * Play a custom animation.
                     * Auto adjusts the animation's rate to match a given duration in seconds.
                     * Supports many features, including blending in and out.
                     *
                     * @param	AnimName		Name of animation to play.
                     * @param	Duration		duration in seconds the animation should be played.
                     * @param	BlendInTime		Blend duration to play anim.
                     * @param	BlendOutTime	Time before animation ends (in seconds) to blend out.
                     *							-1.f means no blend out.
                     *							0.f = instant switch, no blend.
                     *							otherwise it's starting to blend out at AnimDuration - BlendOutTime seconds.
                     * @param	bLooping		Should the anim loop? (and play forever until told to stop)
                     * @param	bOverride		play same animation over again only if bOverride is set to true.
                     */
                    final native function PlayCustomAnimByDuration
                    (
                    	name	AnimName,
                    	float	Duration,
                    	optional	float	BlendInTime,
                    	optional	float	BlendOutTime,
                    	optional	bool	bLooping,
                    	optional	bool	bOverride
                    );
                    to only play the anim for a certain amount of time

                    Comment


                      #40
                      This is what I meant by Tracing done in four directions:




                      Could be something relative to the camera?

                      I'll take a look at the rest of your post and I'll try to understand states before going insane.
                      Thanks again!

                      Cheers.

                      Comment


                        #41
                        Could help to post what you have scripted. Since it appears you're throwing four separate traces...unless you're just using drawdebugs to test your dir. If you want the trace to start at your pawn's location you can remove the TraceAdd var (and wherever it's used) and make
                        Code:
                         StartTrace = ANPAwn(Pawn).Location;
                        This will solve the issue you were having where you would try to adjust the Dir value and it changed the start position of your trace...this way whenever you change the dir var it will only affect the end location of your trace.

                        Another thing I just noticed is we're using your controller's rotation for the Dir, which might cause issues with a sidescroller. Instead you should probably use your pawns rotation, or:
                        Code:
                        Dir=vector(ANPawn(Pawn).Rotation);

                        Comment


                          #42
                          This is what I have so far.
                          Made the changes you pointed out and now it does only one trace
                          I started a state for climbing and I tried Ending the animation by a few ways. Also tried PushState to bring the walking state but without results.
                          I'm still reading about states before going any further.

                          Thanks again!


                          Code:
                          exec function Use()
                          {
                              local Actor  TraceHit;
                              local vector HitLocation, HitNormal, StartTrace, EndTrace, Dir;
                              local float  TraceDist;
                              
                              StartTrace = ANPAwn(Pawn).Location;
                              TraceDist = 45;
                              Dir = vector(ANPawn(Pawn).Rotation);
                              StartTrace = ANPawn(Pawn).Location;
                              StartTrace.Z = 90;
                              
                              EndTrace = StartTrace + (Dir * TraceDist);    
                              TraceHit = Trace(HitLocation, HitNormal, StartTrace, EndTrace, true);
                              DrawDebugLine(StartTrace, EndTrace,255,0,255,true);
                                      
                                      if (TraceHit == none)
                                      {
                                          return;
                                      }
                                                                                
                                       if(TraceHit.IsA('StaticMeshActor'))
                                           {
                                              
                                               StartTrace = ANPawn(Pawn).Location;
                                               GotoState('Climbing');    
                                           }
                                       else
                                           {
                                               GoToState('PlayerWalking');                   
                                           }
                                       return;
                                      }
                          
                          
                          state Climbing
                          {
                              exec function Use()
                          	{
                                 GotoState('Climbing');
                          	   ANPawn(Pawn).SetPhysics(PHYS_Flying);
                                 ANPawn(Pawn).FullBodyAnimSlot.PlayCustomAnim('Climb', 0.5, 0.1, 0.1, FALSE, TRUE); 
                               //ANPawn(Pawn).FullBodyAnimSlot.StopCustomAnim(float BlendOutTime);				
                              }
                                     
                          }

                          Comment


                            #43
                            Hi FraktalZero, i use your code, but i get some error...

                            ETGPawn.uc(252) : Error, Bad or missing expression for token: ETGPawn, in '='

                            any ideas?

                            Comment


                              #44
                              Hi Eumel44, I haven't touched this code for ages since I'm working in another project for now. But feel free to download the scripts. Here's the link.
                              The tracing works but haven't tried it that much.

                              https://www.box.com/s/dmly0qntydwjs11r10t7

                              Cheers.



                              Originally posted by Eumel44 View Post
                              Hi FraktalZero, i use your code, but i get some error...

                              ETGPawn.uc(252) : Error, Bad or missing expression for token: ETGPawn, in '='

                              any ideas?

                              Comment

                              Working...
                              X