Sliding as a contextual crawl?

0 favourites
  • 3 posts
From the Asset Store
A pack of orchestral music that can bring the mood you need in the context.
  • Sorry to bug again so soon but I'm stumped.

    I am trying to set up a simple state machine with Construct 2 for a 2d platformer. I am trying to use states in hopes of simplifying transition animations later on but I'm having a problem with sliding.

    Basically, I want the down key to be the crouched state, down and move to be crawl state but pressing down while running to be slide state. But pressing down while running just triggers crawl.

    Can I not use one state (global variable) to determine when another should be entered or have I just not got this set up right? I tried down arrow is down' and 'down arrow is pressed' but neither worked.

    Here's the .capx if it helps:

    dl.dropbox.com/u/1587144/2D_StateTesting_02.capx

    Thanks in advance.

  • This is a bit hard to explain. Ultimately, your issue is you are resetting your globals to zero constantly, but you are expecting the Running value to be maintained ***from the last iteration***. Running is only set when the down-arrow is NOT down, but Sliding is only set when the down-arrow IS down - you can't have both at once (the way you've done things).

    Ultimately the reset-globals can't work as if you ever needed a global later on as you build up you game, it will constantly be reset to zero!

    Typically a state-machine has a single variable and you change the value based on the state, since you can't be Standing and Running and Jumping, etc. all at the same time. Your odd case is you want to know that you were running previously, and then you want to switch to the sliding state. The rest are not based on history.

    Maybe give that a try.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks for the quick reply and the explanation! That makes sense. I wondered about the Reset Global Variables thing but it seemed to be working for the other stuff.

    I was using the global numbers on and off because I'd seen other people's example projects do it that way. But I understand why it should be a single variable to define them all. I'll start digging in that direction.

    Thanks again!

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