0 Favourites

How do I create a "walk-to-run" key toggle?

  • Hi Everyone!

    I have stumbled upon my first logic problem with Construct 2. I'm creating a game where I want the main character to shift between walking and running while holding down a key. (i.e the "shift"-key.)

    The running mechanics works if I hold down shift before I press ASWD-keys, but I can't toggle between the modes while walking or running. is there any obvious mistake in Event Sheet? Can anyone give me some kind of clue on how to approach this problem?

    (I case you're wondering what's up with all the groups in the picture: my initial thought was to reduce instructions per clock cycle by activating and inactivating groups in the event sheet, but actually don't know if it is doing any good?)

  • Because whenever A or D is down you set group running deactivated and walking activated. Personally, I would give the sprite a variable for whether the character was running or not. Then under the 'A is down' and 'D is down' events, include a sub event with a value comparison on the variable, and create an else to it then have the walking and running methods under there and just have shift toggle that variable.

  • walk-to-run..without Shift key..

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • walk-to-run..without Shift key..

    Thank you, i didn't have any use for this now. But I will look into it, because I'm going to use timers for sprint mechanics, this seem to be of great help.

    Because whenever A or D is down you set group running deactivated and walking activated. Personally, I would give the sprite a variable for whether the character was running or not. Then under the 'A is down' and 'D is down' events, include a sub event with a value comparison on the variable, and create an else to it then have the walking and running methods under there and just have shift toggle that variable.

    Thank you! This helped me a lot getting on the right path.

    This is my Event Sheet today, There's so many things that are being declared over and over again. many things may look a bit necessary, but this was the only way I got everything to work. I use two kind of forward movement, "running" and "walking", I also have two kind of jumps: a "high jump" and a "long jump". It's a lot to take account for, especially since it's just standard jump- and run mechanics... Is there anyone out there that can explain how to make cleaner, less redundant event sheets?

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