Announcement

Collapse
No announcement yet.

Trying to make a UTPawn crouch

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

    Trying to make a UTPawn crouch

    I thought it would be this easy...
    Code:
    Pawn.ShouldCrouch(!Pawn.bIsCrouched);
    That's in a function in my PlayerController. It's not doing anything. Using mostly default everything, I can't get the pawn to crouch. Pressing the C button (which is the default crouch button in DefaultInput.ini) doesn't make the pawn crouch either. Is there a checklist or something that I can follow to make sure a pawn is able to crouch?

    #2
    If you're using the UT classes as your base and you haven't messed around with anything the pawn will crouch if you press c or control.

    Comment


      #3
      I am having a similar issue. I am using UT classes, but c or control does not make the pawn crouch. I have tried this function:

      Code:
      Pawn.StartCrouch(float HeightOffset);
      For the argument, I used -45. I get the crouch to begin, but then the pawn pops right back up.
      Tried to follow it up with Pawn.ShouldCrouch(bool bCrouch) and even bound Pawn.UnCrouch() to the release of the button. No dice.

      Still trying to figure this out.

      Comment


        #4
        Most of the code from Rat's Army dudes: http://www.magicstonestudios.com/tut.../ironsight.php ... is the bookmark I saved but "Home" from that page will get you there.
        Code:
        class KFZPlayerInput extends PlayerInput within KFZPlayerController
        	config(Input);
        
        simulated exec function Duck()
        {
        		if(bDuck == 0) bDuck = 1;
        }
        simulated exec function UnDuck()
        {
        		if(bDuck == 1) bDuck = 0;
        }
        Then in your DefaultInput.ini - (in UDKGame\config\) you need 2 lines:

        .Bindings=(Name="GBA_Duck",Command="Duck | onrelease UnDuck | Axis aUp Speed=-1.0 AbsoluteAxis=100") This initializes the key

        .Bindings=(Name="Delete",Command="GBA_Duck") So as a lefty, I use the Delete Key to Duck.

        Navigate your way around DefaultInput.ini The lines are in totally different areas of the .ini but it should become obvious where they go once you familiarize.

        Comment


          #5
          If I remember correctly, crouching is dependent upon the bDuck variable in PlayerInput, as Snipe mentioned. if the Duck button is down, then ShouldCrouch returns true, and the movement code adjusts for crouching, if it's not down, then shouldcrouch returns false, and it readjusts for standing.

          It's a hold-button not a press-to-turn-on press-to-turn-off.

          Comment


            #6
            Awesome, thanks for the help Snipe and Blade! I am using the Razer Hydra, so I can't use the ini bindings, but assigning bDuck to the button functions did the trick:

            Code:
            function LeftTriggerPress()
            {
            	if(bDuck==0) bDuck = 1;
            }
            
            function LeftTriggerRelease()
            {
            	if(bDuck==1) bDuck=0;
            }
            Thanks once again, excellent advice!

            Comment

            Working...
            X