Hey all,
I'm new to Construct 2, and I'm taking a stab at my first real game (after playing with some of the examples, making a few prototypes, etc.). First of all, this is an awesome engine and an awesome community, so thanks to the Scirra crew for making this!
So, my problem: I have a rolling-platformer type game where I am solely using the "Physics" behavior, not "Platform". The player is a rolling ball, and they can collide with objects (like moveable crates) and platforms (not moveable).
I want to enable jumping in this game (it's the only real action controlled by the player). Currently, I give the player a neg. Y impulse on key press. However, with this method, if you mash the key, you can do infini-jump, and I want to restrict the player to single jump. That said, I want the player to be able to jump again after they have collided with an object below them (this is key, I don't want you to be able to infini-jump up walls).
My current implementation is to give the player an instance variable for jump count, defaulted to 0. The player can only jump when jump count == 0. When they jump, I set jump count to 2, and subtract 1 from this value any time the player's velocityY is close to 0 (-1,+1). Ideally, 1 is subtracted at the peak of the jump, and again on ground contact, and this works well in basic terrain situations.
This does not work well, however, if the player lands on a crate that's on an incline, a sloped platform, etc. It seems like jumping should be possible in these situations, but it's not since the Y velocity hasn't leveled off to 0.
Is there a better way to restrict to single-jump? I know Platform behavior gives recognition when a sprite touches platforms, is there anything like this for Physics behavior?
Thanks!