Sliding as a contextual crawl?

Get help using Construct 2

Post » Fri Jul 06, 2012 6:09 am

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:

Thanks in advance.
Posts: 20
Reputation: 1,015

Post » Fri Jul 06, 2012 7:23 am

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.
Posts: 3,425
Reputation: 95,561

Post » Fri Jul 06, 2012 8:21 am

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!
Posts: 20
Reputation: 1,015

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 9 guests