Page 1 of 2 12 LastLast
Results 1 to 40 of 44
  1. #1
    MSgt. Shooter Person
    Join Date
    Jan 2012
    Location
    Montreal, Canada
    Posts
    238
    Gamer IDs

    PSN ID: polygonaldecay

    Default Ledge Grabing, Wall climbing and Wall running

    Hi,
    I know these topics has been posted a lot around here. I did a lot of searches and I found many solutions. For the climbing system I tried using ladder volume, but it's not really what I want since I would like my character to be able to move around the level in a very fluid manner like in this game.
    http://www.youtube.com/watch?v=iJfJnwoqnPQ

    So basically if anyone could just point me out where to look at in the classes, that would help me a lot to get in the right direction.
    Thanks!

  2. #2
    Iron Guard
    Join Date
    Nov 2006
    Posts
    716

    Default

    I think relatively simple solution would be to set up various states for your Pawn/Controller when their movement should be restricted while performing one of those actions, and use Phys_Flying to have greater control over their movement.

  3. #3
    MSgt. Shooter Person
    Join Date
    Jan 2012
    Location
    Montreal, Canada
    Posts
    238
    Gamer IDs

    PSN ID: polygonaldecay

    Default

    Thanks Blaaguuu for your input.

    For now I'm trying the vaulting system done by TheAgent. Seemed to me like a good option. But actually ran into a problem. The tracing is shown in my test map while running but the animation isn't being played.
    Here is an image of what happens:

    http://www.box.com/s/8re17m2dmh7a2lg9dfhk


    I've been trying to figure out what it is but without result. Also, is it a good idea to use tracing for what I'm trying to accomplish?
    I'll explain:
    I would like to have my character be able to run to a wall and if the wall is of a certain height then it is climbable, if not
    then wall run the climb, also I would like the character to be able to wall jump.

    Any help would be very welcome,
    Thanks in advance,


    Cheers.

  4. #4
    Iron Guard
    Join Date
    Sep 2011
    Posts
    508
    Gamer IDs

    PSN ID: eshwarlion

    Default

    u should make sure ur animtree has animnodeslots and the Source of each connected to the anim u want it to play.

  5. #5
    MSgt. Shooter Person
    Join Date
    Jan 2012
    Location
    Montreal, Canada
    Posts
    238
    Gamer IDs

    PSN ID: polygonaldecay

    Default

    Yes, in my animtree I got the AnimNodeSlots for running and climbing. In the animtree the animations are played correctly. If I use the laddervolume system it works: my character climbs up without problems, but I would prefer doing it throught scripting rather than use the laddervolume in every wall the character might encounter.

  6. #6
    Iron Guard
    Join Date
    Sep 2011
    Posts
    508
    Gamer IDs

    PSN ID: eshwarlion

    Default

    well it is very complicated. in fact i dont think its possible

  7. #7
    Iron Guard
    Join Date
    Sep 2011
    Posts
    508
    Gamer IDs

    PSN ID: eshwarlion

    Default

    Sorry

  8. #8
    MSgt. Shooter Person
    Join Date
    Jan 2012
    Location
    Montreal, Canada
    Posts
    238
    Gamer IDs

    PSN ID: polygonaldecay

    Default

    Thanks blaklion. I'm sure at least a bit of it can be done since the same was done by TheAgent for his vaulting system. Except the result I got was the tracing being shown in the test level.
    Any suggestions anyone?
    Thanks.

  9. #9
    Iron Guard
    Join Date
    Sep 2011
    Posts
    508
    Gamer IDs

    PSN ID: eshwarlion

    Default

    i dont know. i think the DrawDebugLine should b taken off.

  10. #10
    MSgt. Shooter Person
    Join Date
    Jan 2012
    Location
    Montreal, Canada
    Posts
    238
    Gamer IDs

    PSN ID: polygonaldecay

    Default

    took it off but still getting the trace lines on the level and still can't get the character to climb.

  11. #11
    MSgt. Shooter Person
    Join Date
    May 2010
    Location
    Vienna, Austria
    Posts
    123

    Default

    Actually its perfectly possible to do this by scripting. I'm not completely sure you TheAgent did it, but mostly you will detect ledges / walls / whatever by doing (many) traces. While climbing /ledge grabbing you should use PHYS_Flying, as this gives you the best control on what a Pawn can do while climbing.
    Though, it will take quite some work until this really works smooth.

  12. #12
    MSgt. Shooter Person
    Join Date
    Jan 2012
    Location
    Montreal, Canada
    Posts
    238
    Gamer IDs

    PSN ID: polygonaldecay

    Default

    Thanks. I'm still trying to understand the whole process of tracing. I get the idea of how it works but I'm still suffering headaches trying to get what every piece of code does lol
    In the PlayerController, after adding the tracing, should I add a state with phys_flying. Actually I'm using phys_flying just in the animtree.

  13. #13
    MSgt. Shooter Person
    Join Date
    Jan 2012
    Location
    Montreal, Canada
    Posts
    238
    Gamer IDs

    PSN ID: polygonaldecay

    Default

    Should I add the tracing into the pawn class, actor or PlayerController class? For what I've been reading it should be in the actor class but I'm not sure. Any help?
    Thanks in advance.

  14. #14
    Iron Guard
    Join Date
    Sep 2011
    Posts
    508
    Gamer IDs

    PSN ID: eshwarlion

    Default

    playercontroller i think

  15. #15
    MSgt. Shooter Person
    Join Date
    Jan 2012
    Location
    Montreal, Canada
    Posts
    238
    Gamer IDs

    PSN ID: polygonaldecay

    Default

    Thanks baklion!

  16. #16
    Iron Guard
    Join Date
    Sep 2011
    Posts
    508
    Gamer IDs

    PSN ID: eshwarlion

    Default

    no prob

  17. #17

    Default

    you can trace from any actor class. Trace works with a start location and an end location. Preferably i would leave the trace on the pawn to avoid casting the location and rotation and all the vector caculations, much easier to have a check if i have a wall infront of me then switch states on the controller.
    Released Games:
    -Fridge Raider
    -Laser Vault

    Upcoming Titles:
    -Raid
    -Epar

    Demo Reel 2011 (WIP):
    -Demo 2011 (WIP)

  18. #18
    MSgt. Shooter Person
    Join Date
    Jan 2012
    Location
    Montreal, Canada
    Posts
    238
    Gamer IDs

    PSN ID: polygonaldecay

    Default

    Quote Originally Posted by Acecutter69 View Post
    you can trace from any actor class. Trace works with a start location and an end location. Preferably i would leave the trace on the pawn to avoid casting the location and rotation and all the vector caculations, much easier to have a check if i have a wall infront of me then switch states on the controller.
    Thanks Acecutter69. So I've been trying to figure out the tracing and so far I understand the concept. But I came across some problems.

    Code:
    class ANPawn extends UTPawn;
    
    
    var name ClimbStartSocketName;
    var name ClimbEndSocketName;
    var bool SkeletalMeshComponent;
    	
    
    exec function Use()
    {
    	local Actor TraceHit;
    	local vector HitLocation, HitNormal, HitPawn;
    	local vector StartTrace, EndTrace;
    	local Vector HitInfo;
    	
    
    			//Trace from socket locations
    			Pawn.StaticMeshActor.GetSocketWorldLocationAndRotation(ClimbStartSocketName, StartTrace);
    			Pawn.StaticMeshActor.GetSocketWorldLocationAndRotation(ClimbEndSocketName, EndTrace) + vector(Rotation);
    			
    			Trace(HitLocation, HitNormal, HitInfo, HitPawn, StartTrace, EndTrace,true);
    			DrawDebugLine(StartTrace, EndTrace,255,0,255,true);
    
    			`log( "Command Trace");
    			ClientMessage("");
    
    			if (TraceHit == none)
    			{
    				ClientMessage("Nothing found, try again.");
    				return;
    			}
    								
    			
    			
    
    			 if(TraceHit.IsA('StaticMeshActor'))
    				 {
    					 GotoState('Climbing');
    					 SetPhysics(PHYS_Flying);
    					 FullBodyAnimSlot.PlayCustomAnim('Climb', 0.5, 0.1, 0.1, FALSE, TRUE);
    				 }
    	  
    	  
    
    	}
    In the error message it says Pawn bad command. If I use SkeletalMeshComponent I get another error message. I'm kind of lost.
    Thanks in advance!

  19. #19
    MSgt. Shooter Person
    Join Date
    Feb 2012
    Location
    Bulgaria, Sofia
    Posts
    123

    Default

    Just remove the Pawn. , you are already in the Pawn class.
    I'm a bit confused why you are trying to trace from one socket to another, instead of just tracing a vector to see if it hits anything.

    I would not even trace from sockets, I'd just trace from the pawn itself towards the view rotation. Doing it your way is much more painfull, but will probably give you the precision to determine exactly if there is a wall near the socket, thus allowing for "grabs" only with the hand that has a wall nearby.
    In darkness born, to light devoted.
    Code:
    /** What the f*ck per minute - KPI for source readability,  How the hell per second - KPI for code functionality */ 
    var int _iWtfPMin, _iHthPSec;
    if( _iWtfPMin > _iHthPSec ) { Developer(CodeOwner).SetOnFire( Napalm, noDelay ); }

  20. #20
    MSgt. Shooter Person
    Join Date
    Jan 2012
    Location
    Montreal, Canada
    Posts
    238
    Gamer IDs

    PSN ID: polygonaldecay

    Default

    Thanks Dragon666!
    I didn't know using sockets would be more difficult. I just thought that way I could control whether the character walljumps, wallrun or climb.

  21. #21
    MSgt. Shooter Person
    Join Date
    Jan 2012
    Location
    Montreal, Canada
    Posts
    238
    Gamer IDs

    PSN ID: polygonaldecay

    Default

    Sadly, still having problems.

    I modified some lines but with no luck.
    Code:
    class ANPawn extends UTPawn;
    
    var name ClimbStartSocketName;
    var name ClimbEndSocketName;
    
    exec function Use()
    {
    	local Actor  TraceHit;
    	local vector HitLocation, HitNormal, HitPawn;
    	local vector StartTrace, EndTrace;
    	local Vector HitInfo;
    	
    
    			//Trace from socket locations
    			Mesh.GetSocketWorldLocationAndRotation(ClimbStartSocketName, StartTrace);
    			Mesh.GetSocketWorldLocationAndRotation(ClimbEndSocketName, EndTrace);
    			
    			Trace(HitLocation, HitNormal, HitPawn, StartTrace, EndTrace, HitInfo, true);
    
    			DrawDebugLine(StartTrace, EndTrace,255,0,255,true);
    
    			`log( "Command Trace");
    			ClientMessage("");
    
    			if (TraceHit == none)
    			{
    				ClientMessage("Nothing found, try again.");
    				return;
    			}
    								
    						
    			 if(TraceHit.IsA('StaticMeshActor'))
    				 {
    					 GotoState('Climbing');
    					 SetPhysics(PHYS_Flying);
    					 FullBodyAnimSlot.PlayCustomAnim('Climb', 0.5, 0.1, 0.1, FALSE, TRUE);
    				 }
    	  
    	 
    	}
    
    defaultproperties
    
    {
       ClimbStartSocketName = ClimbStart
       ClimbEndSocketName   = ClimbEnd
    	
    }
    The error says: Error, Type mismatch in Call to 'Trace', parameter 5
    is it because of the order in which I put them? Or did I forget something else?

    Thanks in advance!

  22. #22

    Default

    Seems like you mixed up the parameters for Trace. The function head is
    Code:
    function Actor Trace
    (
    	out vector			HitLocation,
    	out vector			HitNormal,
    	vector				TraceEnd,
    	optional vector			TraceStart,
    	optional bool			bTraceActors,
    	optional vector			Extent,
    	optional out TraceHitInfo	HitInfo,
    	optional int			ExtraTraceFlags
    );
    So your call of the Trace-Function should probably be
    Code:
    Trace(HitLocation, HitNormal, StartTrace, EndTrace, true, , HitInfo);
    I just noticed, that there are some other things messed up as well. I'll copy your code and put comments in those lines that might be incorrect or causing problems.

    Code:
    exec function Use() {
    
        // This variable never has any value assigned, it will always be none
        local Actor  TraceHit; 
    
        // HitLocation and HitNormal are fine, HitPawn is not needed as seen in the 
        // Trace call above
        local vector HitLocation, HitNormal, HitPawn; 
    
        local vector StartTrace, EndTrace;
    
        // First: I'm not even sure if HitInfo is needed in this particular case
        // Second: If you're going to use it, the Variable should be of Type 
        // TraceHitInfo as seen above
        local Vector HitInfo; 
    
    
        //Trace from socket locations
        Mesh.GetSocketWorldLocationAndRotation(ClimbStartSocketName, StartTrace);
        Mesh.GetSocketWorldLocationAndRotation(ClimbEndSocketName, EndTrace);
    
        // This Trace is messed up, see above
        // Also: Since you want to use the actor that was hit by this trace, you 
        // have to assign the result of this function-call to your variable TraceHit
        // TraceHit = Trace(HitLocation, HitNormal, StartTrace, ...);
        Trace(HitLocation, HitNormal, HitPawn, StartTrace, EndTrace, HitInfo, true);
    
        DrawDebugLine(StartTrace, EndTrace,255,0,255,true);
    
        `log( "Command Trace");
        ClientMessage("");
    
        if (TraceHit == none) {
            ClientMessage("Nothing found, try again.");
            return;
        }                
                
        if(TraceHit.IsA('StaticMeshActor')) {
            GotoState('Climbing');
            SetPhysics(PHYS_Flying);
            FullBodyAnimSlot.PlayCustomAnim('Climb', 0.5, 0.1, 0.1, FALSE, TRUE);
        }
    }
    Last edited by Denara; 02-18-2012 at 05:09 PM.
    My german game development blog:
    http://blog.2digitalgames.de

  23. #23
    MSgt. Shooter Person
    Join Date
    Jan 2012
    Location
    Montreal, Canada
    Posts
    238
    Gamer IDs

    PSN ID: polygonaldecay

    Default

    Thanks Denara! That was really helpful!
    The code so far:
    Code:
    class ANPawn extends UTPawn;
    
    var name ClimbStartSocketName;
    var name ClimbEndSocketName;
    
     
    exec function Use()
    {
    	local Actor  TraceHit;
    	local vector HitLocation, HitNormal;
    	local vector StartTrace, EndTrace;
    	
    	
    			//Trace from socket locations
    			Mesh.GetSocketWorldLocationAndRotation(ClimbStartSocketName, StartTrace);
    			Mesh.GetSocketWorldLocationAndRotation(ClimbEndSocketName, EndTrace);
    			
    			TraceHit = Trace(HitLocation, HitNormal, StartTrace, EndTrace, true);
    			Trace(HitLocation, HitNormal, StartTrace, EndTrace, true);
    
    			DrawDebugLine(StartTrace, EndTrace,255,0,255,true);
    			
    			 if(TraceHit.IsA('StaticMeshActor'))
    				 {
    					 GotoState('Climbing');
    					 SetPhysics(PHYS_Flying);
    					 FullBodyAnimSlot.PlayCustomAnim('Climb', 0.5, 0.1, 0.1, FALSE, TRUE);
    				 }
    	  
    	}
    defaultproperties
    {
    
       ClimbStartSocketName = ClimbStart
       ClimbEndSocketName   = ClimbEnd
    	
    }
    So I'm going to continue my batch of noob questions
    Is it actually working? I haven't add the PHYS_Flying node to my AnimTree yet, so I don't know if it's actually working or not.
    Do I have to assign a key in DefaultInput.ini for the Climb action to be executed?

    Also, I would like to add a condition in which if I don't keep pressing the key, the character fall rather than climb. But I haven't found anything related to this
    type of code in the UT Scripts.

    I suppose it would be something like:

    if(TraceHit.IsA('StaticMeshActor'))
    {
    GotoState('Climbing'); //I suppose it should be GoToState('Ledge'); and then execute the Climb action after the proper keyinput is pressed??
    SetPhysics(PHYS_Flying);

    //if else (And here add the condition??)

    Sorry about all these questions. So far I've been learning a lot.
    Thanks in advance!
    Last edited by FraktalZero; 02-20-2012 at 09:48 AM.

  24. #24
    MSgt. Shooter Person
    Join Date
    Jan 2012
    Location
    Montreal, Canada
    Posts
    238
    Gamer IDs

    PSN ID: polygonaldecay

    Default

    After adding the proper nodes for PHYS_Flying with a very simple climb animation, my character still not detecting the wall when I press UP. What am I doing wrong here?
    Thanks in advance!

  25. #25
    MSgt. Shooter Person
    Join Date
    Dec 2010
    Location
    USA
    Posts
    92

    Default

    Quote Originally Posted by FraktalZero View Post
    Thanks Dragon666!
    I didn't know using sockets would be more difficult. I just thought that way I could control whether the character walljumps, wallrun or climb.
    It's not more difficult, it's just unnecessary to add sockets to a mesh when you can easily calculate the vectors for your trace based upon the amount of available information you have.

    Here's an example how you could achieve this without using sockets:
    Code:
    exec function Use()
    {
    	local Actor  TraceHit;
    	local vector HitLocation, HitNormal, StartTrace, EndTrace, Dir;
        local float TraceDist, TraceAdd;   //both of these values will be equivalent in uu's
    
        //A little wiggle room so the trace doesn't start too close to us
        TraceAdd = 5;
        //Max range for this trace
        TraceDist = 45;
        //Find the Pawn's Rotation & convert it to a vector
        Dir = vector(Rotation);
        //Multiply the pawn's rotation vector by TraceAdd so it doesn't start too close to the pawn, and add that to the pawn's location
        TraceStart = Location + (Dir * TraceAdd);
        //Same thing but multiply by the TraceDistance to find our end point
        TraceDest = TraceStart + (Dir * TraceDist);    	
        //Throw the trace	
        TraceHit = Trace(HitLocation, HitNormal, StartTrace, EndTrace, true);
        //Draw It
        DrawDebugLine(StartTrace, EndTrace,255,0,255,true);
    	//if TraceHit == none, our trace didnt hit anything	
        if (TraceHit == none) 
        {
               //so return
               return;
         }        	
         //else if it did hit something...
         else if (TraceHit != none )
         {
            //and its a static mesh actor...
            if ( TraceHit.IsA('StaticMeshActor') )
    	    {
               //do stuff...
               GotoState('Climbing');
    	       SetPhysics(PHYS_Flying);
    	       FullBodyAnimSlot.PlayCustomAnim('Climb', 0.5, 0.1, 0.1, FALSE, TRUE);
    	    }
         }
    	  
    }
    This will trace out in the direction the pawn is facing at about knee height. This can be manipulated to any height rather simply by altering the Z component of the StartTrace vector.
    So if you wanted to start the trace at eye level you could do something like this after you set TraceStart:

    Code:
    TraceStart.Z = BaseEyeHeight
    Other than that there is nothing for us to help with b/c we don't know what's in your climbing state...
    If it's what the Agent scripted it will most likely not work as his system retrieves info from the VaultActors in order to manipulate the pawn's velocity over it.

    If your Use() function is not registering with the IsA('StaticMeshActor') tag you might simply start with a if (TraceHit != none) conditional to first see if you hit anything at all (as in the above example). Afterwards, you can fan out from there additional behavior based upon what your trace hit.

    You could do this many ways as traces always provide alot of information in HitInfo (like material, physical material, bone name, component, index# [if its bsp], etc.)

    Quote Originally Posted by FraktalZero View Post
    Also, I would like to add a condition in which if I don't keep pressing the key, the character fall rather than climb. But I haven't found anything related to this
    type of code in the UT Scripts.
    Actually, if you look in the DefaultInput.ini there are many examples of keys which have two functions that it calls on press/release.
    here's an example:

    Code:
    .Bindings=(Name="GBA_Fire",Command="StartFire | OnRelease StopFire")
    This is a simple example...but you could say do something like this:

    Code:
    .Bindings=(Name="GBA_Use",Command="Use | OnRelease CheckClimb")
    Where CheckClimb() (or whatever you choose to name the function) could check for player input and either allow them to keep climbing based upon movement keys / or continued holding of the "use" key, etc. really just depends on how you want to design it...


    Quote Originally Posted by FraktalZero View Post
    After adding the proper nodes for PHYS_Flying with a very simple climb animation, my character still not detecting the wall when I press UP. What am I doing wrong here?
    Thanks in advance!
    Well, first off... is the "UP" key in your DefaultInput.ini bound to GBA_Use?
    Are you sure the "Wall" you're using is a StaticMeshActor?
    while (!bSucceed)
    try();

    Quote Originally Posted by Run2300 View Post
    UDK now very powerful gay! The consequences will be severe!

  26. #26
    MSgt. Shooter Person
    Join Date
    Jan 2012
    Location
    Montreal, Canada
    Posts
    238
    Gamer IDs

    PSN ID: polygonaldecay

    Default

    Thanks .Wrath,
    That was a very educative post. Now I understand much more about the trace function. But I still have a few questions:

    You said something about my climbing state. I haven't created it yet. Should be add in my Pawn class after the trace function?
    Do I have to do a new trace from there and set the physics and custom animation from there as well?

    Also, to create a new key input is it done by creating a new GBA? Like exemple: .Bindings=(Name="GBA_Climb",Command="Climb") which could be triggered by 'E'?

    if my character grabs a ledge and then either falls or climb, should I create a state for both actions?

    Sorry for having so many questions, I'm still learning, but thanks for the patience and great help.

  27. #27
    MSgt. Shooter Person
    Join Date
    Dec 2010
    Location
    USA
    Posts
    92

    Default

    Quote Originally Posted by FraktalZero View Post
    You said something about my climbing state. I haven't created it yet. Should be add in my Pawn class after the trace function?
    The state itself can be in either the playercontroller or the pawn. typically exec functions reside in the player controller b/c the playerinput class resides "within" it.

    Quote Originally Posted by FraktalZero View Post
    Do I have to do a new trace from there and set the physics and custom animation from there as well?
    You don't have to do anything...but you should do things that make sense to achieve your intended goal.
    Again, you can set physics and play animations from either class...it just changes the syntax.

    For Example...

    From the Pawn:
    Code:
    	       SetPhysics(PHYS_Flying);
    	       FullBodyAnimSlot.PlayCustomAnim('Climb', 0.5, 0.1, 0.1, FALSE, TRUE);
    From the PlayerController:
    Code:
    	       ANPawn(Pawn).SetPhysics(PHYS_Flying);
    	       ANPawn(Pawn).FullBodyAnimSlot.PlayCustomAnim('Climb', 0.5, 0.1, 0.1, FALSE, TRUE);
    Quote Originally Posted by FraktalZero View Post
    Also, to create a new key input is it done by creating a new GBA? Like exemple: .Bindings=(Name="GBA_Climb",Command="Climb") which could be triggered by 'E'?
    Yes. Bindings come in pairs in two different sections of DefaultInput.ini. You can either alter the existing entries or add your own to handle what you want to do.
    The two entries are as such if you wanted to bind Climb() to key "E":
    Code:
    .Bindings=(Name="GBA_Climb",Command="Climb")
    .Bindings=(Name="E",Command="GBA_Climb")
    they go in two different sections of the file which should be self explanatory if you look through it.
    Yes, the GBA_<Name> can be whatever you want it to be.

    Quote Originally Posted by FraktalZero View Post
    if my character grabs a ledge and then either falls or climb, should I create a state for both actions?
    Yes, you could handle it that way. States are just another tool we are given to script, like any other tool its use is at its owners discretion and preference.
    Although, it seems you do not fully understand states so you may either want to either research them a bit more, or try to achieve what you want without them (yes it is possible).
    Last edited by .Wrath; 02-22-2012 at 03:50 AM.
    while (!bSucceed)
    try();

    Quote Originally Posted by Run2300 View Post
    UDK now very powerful gay! The consequences will be severe!

  28. #28
    MSgt. Shooter Person
    Join Date
    Jan 2012
    Location
    Montreal, Canada
    Posts
    238
    Gamer IDs

    PSN ID: polygonaldecay

    Default

    Thanks again .Wrath. very useful post again.
    So now I got my trace exec function in my PlayerController. Also added the new input in the DefaultInput.ini.

    So far I understand that:

    There's a trace to check if there's a ledge, the tracing goes back to mesh with the info. if true then go to Climb, if false then something else.
    After setting the new input in the DefaultInput, I should create a state Climb so it works.

    My problem now is that as you mentioned it before, I don't fully understand the states. I checked the info in the UnrealScriptHome and I understood a great deal but still don't know how
    to make a custom state. Is there any other place in which I could have more info about it?

    Thanks!

    (I'm an artist trying to figure out scripting so that's the main reason of me being helpless )

  29. #29
    MSgt. Shooter Person
    Join Date
    Dec 2010
    Location
    USA
    Posts
    92

    Default

    Although theAgent's system may not be what you're looking for, his states are fairly nicely handled so if you look through how he did it, it may give you a better idea of how you would want to approach it.

    EDIT: Also, the code posted above should work even if there is no state. If you've setup your anim it should play when you call this function.
    Last edited by .Wrath; 02-22-2012 at 05:26 PM.
    while (!bSucceed)
    try();

    Quote Originally Posted by Run2300 View Post
    UDK now very powerful gay! The consequences will be severe!

  30. #30
    MSgt. Shooter Person
    Join Date
    Jan 2012
    Location
    Montreal, Canada
    Posts
    238
    Gamer IDs

    PSN ID: polygonaldecay

    Default

    Thanks again .Wrath

    This is my AnimTree. If I use a Ladder Volume, the character executes the movement. But is not working with the trace.




    This is my code

    PlayerController.uc

    Code:
    class ANPlayerController extends UTPlayerController
    	dependson(ANPawn)
    	dependson(UTPlayerReplicationInfo)
    	config(Game);
    
    var bool SkeletalMeshComponent;
    var bool StaticMeshActor;
    
    //Trace Function
    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 = HitLocation + (Dir * TraceAdd);
    	
    	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);
    				 }
     
    	}
    
    //Climb State 
    state Climb
    {
    
     function Check()
     {
    
    
     }
    }
    Also I added my input in the DefaultInput.ini file:

    .Bindings=(Name="GBA_Climb",Command="Climb") under Bindings used to organize...
    .Bindings=(Name="W",Command="GBA_Climb") under Game Keyboard/Mouse Bindings

  31. #31
    MSgt. Shooter Person
    Join Date
    Dec 2010
    Location
    USA
    Posts
    92

    Default

    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.
    while (!bSucceed)
    try();

    Quote Originally Posted by Run2300 View Post
    UDK now very powerful gay! The consequences will be severe!

  32. #32
    MSgt. Shooter Person
    Join Date
    Jan 2012
    Location
    Montreal, Canada
    Posts
    238
    Gamer IDs

    PSN ID: polygonaldecay

    Default

    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?

  33. #33
    MSgt. Shooter Person
    Join Date
    Dec 2010
    Location
    USA
    Posts
    92

    Default

    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).
    Last edited by .Wrath; 02-23-2012 at 01:06 PM.
    while (!bSucceed)
    try();

    Quote Originally Posted by Run2300 View Post
    UDK now very powerful gay! The consequences will be severe!

  34. #34
    MSgt. Shooter Person
    Join Date
    Jan 2012
    Location
    Montreal, Canada
    Posts
    238
    Gamer IDs

    PSN ID: polygonaldecay

    Default

    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!

  35. #35
    MSgt. Shooter Person
    Join Date
    Dec 2010
    Location
    USA
    Posts
    92

    Default

    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.
    Last edited by .Wrath; 02-23-2012 at 08:36 PM.
    while (!bSucceed)
    try();

    Quote Originally Posted by Run2300 View Post
    UDK now very powerful gay! The consequences will be severe!

  36. #36
    MSgt. Shooter Person
    Join Date
    Jan 2012
    Location
    Montreal, Canada
    Posts
    238
    Gamer IDs

    PSN ID: polygonaldecay

    Default

    .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!

  37. #37
    MSgt. Shooter Person
    Join Date
    Jan 2012
    Location
    Montreal, Canada
    Posts
    238
    Gamer IDs

    PSN ID: polygonaldecay

    Default

    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!

  38. #38
    MSgt. Shooter Person
    Join Date
    Jan 2012
    Location
    Montreal, Canada
    Posts
    238
    Gamer IDs

    PSN ID: polygonaldecay

    Default

    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)

  39. #39
    MSgt. Shooter Person
    Join Date
    Dec 2010
    Location
    USA
    Posts
    92

    Default

    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?

    Quote 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);
    	 }	 
    }
    Quote 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

    Quote 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
    Last edited by .Wrath; 02-27-2012 at 04:22 PM.
    while (!bSucceed)
    try();

    Quote Originally Posted by Run2300 View Post
    UDK now very powerful gay! The consequences will be severe!

  40. #40
    MSgt. Shooter Person
    Join Date
    Jan 2012
    Location
    Montreal, Canada
    Posts
    238
    Gamer IDs

    PSN ID: polygonaldecay

    Default

    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.


 
Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Copyright ©2009-2011 Epic Games, Inc. All Rights Reserved.
Digital Point modules: Sphinx-based search vBulletin skin by CompletevB.com.