walk run

From the Asset Store
Game "Word Search" with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • i want to do: a+keyleftor right run and key left or right walk(platform game)

    what is the easiest way to do that , should have to use variables?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • What I have been doing for this is just to make some adjustements to my event sheets. I created 2 variables, one called playerBaseSpeed and one called playerRunSpeed. I set playerBaseSpeed to whatever my normal walking speed is, and playerRunSpeed to whatever my running speed is, in my case base is 330 and run is 600. I then have an event for my run button keydown event where if it is down the speed is set to playerRunSpeed, else it is set to playerBaseSpeed. This seems to work well for me so far. The next thing I need to do is set the animation speed when he is running so the legs moving matches the new speed a bit better.

    This has a few benefits, I don't have to alter my keyleft or right events since the Run button (in my case B) handles the speed changes as needed. Also I can add extra logic later for example what if I have a powerup that ups the run speed even more? Then I can have an event that says if speedPowerUp is on, set playerRunSpeed to 900, else set it to 600. This gives you a lot of flexibility. You could also create constants for basespeed and runspeed if you want, then in your events you could just reference those if you don't see a need to change them.

  • ok i guess you add your two variables in the object , i'm confusing about the code can you write it?

    i guess

    variable is run: set speed at 600

    variable is walk set speed at 300

    key left : set variable to walk

    key left+a : set variable to run

  • Here is how I have it setup in my Event Sheet, I am very new to construct 2, so if anyone has a more efficient way let me know. My background is as a developer so I am used to writing it in code as opposed to event sheets. Here is how my event sheet is setup:

    I have two global variables in my eventsheet:

    Global number playerRunSpeed = 600

    Global number playerBaseSpeed = 330

    I then have an event for the player holding the run button:

    Keyboard B is down Player Set Platform maximum speed to playerRunSpeed

    System Else Player Set Platform maximum speed to playerBaseSpeed

    It doesn't matter if they have the left or right arrow down, as long as they have the B button held down, the maximum player speed is set to my run speed. If they are not moving this doesn't do anything, if they are moving they get the new maximum speed. You can also play with this a bit by setting the acceleration, etc... as needed if you want them to not instantly be going max speed when you hit the run button. I have also attached a screenshot of how it looks in my event sheet on skydrive, but as I am new to the scirra site I cannot post links yet. If you want me to send you the screenshot via email or some other method just let me know.

  • The above also has the benefit that as long as they are not holding down the run button it will set their speed back to the regular speed you chose.

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