How do I change platform speed of player from walk to run?

0 favourites
  • 11 posts
From the Asset Store
Full game Construct 2 and Construct 3 to post on Google Play
  • So I searched the forums/tutorials and have come up short.

    Objective: To make the player (with platform behavior) to switch between walk to run when desired.

    I've added variables: Run. If Run is = to or greater than 3, then player should run and animation changes to running.

    Player presses "D" > Set maximum speed to 80

    > Simulate Platform Pressing Right

    > Set animation to WALK

    >Add 2 to RUN (Variable)

    - D released > Subtract 1 from RUN (Variable)

    I'm trying to make it so if D is pressed within " = to or less than 0.05 seconds than add 2 to RUN (Variable)

    Then the actions are:> Set maximum speed to 150

    > Set animation to RUN

    When released set RUN (Variable) to 0 or subtract 1 from it.

    If not pressed within that time, then Set RUN (Variable) to 0 (So the action starts over again and this way the player can switch from walk to run or vise versa at anytime.

    The problem I'm thinking is there is no SET SPEED attribute to the PLATFORM BEHAVIOR only SET MAXIMUM SPEED. (I do have the player pinned to the Player Shadow Box and made sure that is what is used in the events, except for the Player's actual animation.) I can get the player to walk when pressing Down, but can't trigger the rest.

    Anyone have an example or way to pull this off?

  • I don't have an example, but I will say that "set speed" can be done with "set vector x," but you will have to take care of directions explicitly, and the speed won't hold if you don't also adjust the max speed.

  • I almost figured it out. Only problem with this, is if I hit "D" once, release, hit "D" again (Button_Direction_Right2) goes to 2. I still want to tap the "D" button twice to trigger run, but before I hit second quick press with D, Button_Direction.Right2 goes to 3 and automatically resets back to idle.

    My other problem is the the "RUN" animation doesn't work. I have it set to loop and I tried changing the speed within the animation editor itself, but it hasn't helped.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Use the follow conditions:


    On Player Moved: Change animation to "Walking"


    Player is moving AND Player speed > 80: Change sprite animation to "Running"

    ELSE: Change animation to "Walking"

  • I put together this example file. (Google Drive treats capx files strangely. Just click the "download" button in the top right.)

    To keep the player from running after the first tap, I put the conditions for the first and second taps as subevents of an "on D pressed" condition, separated with an "else."

    I also noticed 0.05 seconds wasn't really enough time to double-tap. I barely managed to do it with the timer set to 0.25!

  • TELLES0808 Thanks for the suggestion.

    CALEBBENNETTS Thanks. I just solved it, but I'm going to look at your example too to see if it might be more efficient. I appreciate you taking the time to make it. I added the conditions "On Landed" tied in "Platform Speed = 80 (and a separate one for 140) then put all the necessary actions to match the speed and so forth.

    My next goal is to tackle climbing a rope/ladder/pole...etc. I have the player climbing up. I also have the player climbing down with animation working. (S_PLATFORM is just the invisible shadow the character is pinned too)




    and with UP arrow (JUMP) is down than the actions vary a bit with JUMPSTRENGTH/6 though instead of MAXFALLSPEED/3

    My 2 problems are this:

    1. If I stop climbing or descending, the player slides down the pole instead of just staying paused and holding his position.

    I tried a separate event by inverting up (or down) arrow is down and state is "CLIMBING" then actions are Stop animation and then set animation to "CLIMB."

    2. When I set the player on the ground floor, he climbs the pole. He is then stopped, when the S_PLATFORM (shadow) hits the above solid platform. I tried disabling the solid behavior, but can't figure approximately how to enable it again once S_PLAYER reaches what looks like the top of above platform.

    Also, I imagine if I can figure it out, I can then make it work if I was starting from the top platform and climb down the pole being able to get through the solid platform/ground.

    Thanks again you two for your help. I truly appreciate it.

  • Set its gravity to 0 while climbing and reset it when pressing side keys.

  • TELLES0808 Here is what I have. I also added Set Gravity to 0 (not in this picture) under the events 56 and for 57.

    I can climb and the animation works. When I go down, the animation stops (which is fine, because he is sliding down a pole). He does now stay on the poll until a direction is pressed. I just need to make it so when I press up and I stop part way, that the animation will stop. Been working at it for quite sometime. Any suggestions as to where I should put or add a sub event/action/ or even a new condition? I've tried "ELSE" in different spots, but same results. My next thing I'm also trying to tackle is when I jump and near a ledge, I want to grab it. I've created invisible ledge sprites that I place at the ends of higher up platforms or shimmy horizontal poles. I have animation for when he grabs it and I also have animation for when he wants to climb up or shimmy. Just not sure how to get it to work right. I've been reading some tutorials, but using those interferes with my other inputs. Thanks again for your time on this.

    And anyone who else who is or willing to help.

  • I'm working in a cheap template for C2 where climbing will be part of it, like swimming, climbing wall, stair, ladder, roof, edges, etc.

    But while it's not ready, I'll share something with you:

  • TELLES0808

    Thanks. Looking forward to the template. I'm going to try this while I'm working on ledge grabbing and shimming across. I also need to figure a way to swing back and forth while holding ledge to build momentum and make a bigger leap over the gap.

    Thanks again!

  • TELLES0808

    Thanks. Looking forward to the template. I'm going to try this while I'm working on ledge grabbing and shimming across. I also need to figure a way to swing back and forth while holding ledge to build momentum and make a bigger leap over the gap.

    Thanks again!

    It will be covered too, auto climbing edges was one of my goals to make the use of the 56 pixelart poses fully. I'm finishing the behaviors and making an original tileset, plus, the code need some improvements to reach the minimum number of events and give to the user more than 50 events to run her/his game.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)