Announcement

Collapse
No announcement yet.

WASD - Walk and Run

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

    WASD - Walk and Run

    Good evening,

    I was hoping someone might be able to point me in the right direction, I have started the Top Down example and trying to alter it to suit my needs, have got WASD key movements working however now I want to add a modifier such as HOLD SHIFT to run. Below are how I managed to get my character moving.

    Yes I have googled and searched and really cant seem to get something working, also this is my first time posting so be gentle

    Thanks

    Click image for larger version

Name:	wasd.jpg
Views:	1
Size:	66.5 KB
ID:	1154471
    Click image for larger version

Name:	Capture.jpg
Views:	1
Size:	31.9 KB
ID:	1154472

    #2
    As long as you don't want to have stamina or such things, you can create an "Action Mapping" for your shift key.

    Then you get the Key Event like you did with the others. Grab your CharacterMovementComponent and set the "MaxWalkSpeed" to a higher value
    when the base value (you can see the base value on the right side when you select the component). Place this Set node behind "Pressed" of the key event.
    Then, create a second Set Node for the MaxWalkSpeed and place it behind the "Released". Put in the base value the player should move when
    not sprinting.

    If you want to have stamina reducing and such things, you would need to work with Event Tick and a bool that is true for sprinting and false for not.

    You would set the bool to true or false behind the KeyEvent instead of the MaxWalkSpeed and in the Event Tick, you would reduce the Stamina variable
    as long as the bool is true and add a value to it as long as the bool is false (to regain stamina). You would also check the value in the tick and set the
    MaxWalkSpeed higher as the base value if stamina is greater than 0, otherwise reset the Speed again to the base value.

    I don't have much time to post pictures right now, but i'm pretty sure you will find things on google for this. I know you already googled, but to be honest,
    this is so basic, this has been asked SEVERAL times (: I even answered i few of this questions in the past. Check the AnswerHUB.
    Open for contracted work | C++/BP (incl. Multiplayer) | Tutoring | VR

    My UE4 Blog/Page with Tutorials and more: Hit me for ALL the things!
    (Including 100+ Pages Multiplayer Network Compendium to get you started.)

    Comment


      #3
      Thank you very much for your help, got it working. Look forward to becoming a more active member of the UE forums.

      Comment

      Working...
      X