Bottom Collision and Jumping [SOLVED]

Zionviller

  • Posts: 2
So, to get to know Stencyl, I'm trying to home grow some platformer code. But I've run into an issue.

I'm trying to implement some jump limiting code with the possibility of a double or triple jump, but I'm having an issue were the count of jumps gets instantly reset just after leaving the ground.

See it here (WASD controls):http://www.stencyl.com/game/play/14255

This should only be a single jump, but you get a double.

Anyone have a clue what could be going on?

Here's what I got:
Two attributes:
numJumps:Number = Max number of jumps
curJumps:Number = whatever the current number of jumps is

Here's my jump code blocks:


Here's my collide bottom code blocks:


Is there something going on behind the scenes of Stencyl that I don't know about? Or do I have to order my Events in such a way that makes it work? (I couldn't figure one out)

Any help would be appreciated! Thanks!

« Last Edit: August 20, 2012, 09:22:22 pm by Zionviller »

rob1221

  • *
  • Posts: 9473
You'll need a short delay to stop that from happening.  Make a new boolean attribute that you change when you jump, and use it to stop curJumps from changing just after jumping.  So if you made a boolean attribute called Collision Delay:

When Created
---set Collision Delay to false

Always
---if up was pressed and curJumps > 0
------set Y-speed to -40
------decrement curJumps by 1
------set Collision Delay to true
------do after 0.05 seconds
---------set Collision Delay to false

On Collision
---if bottom of actor1 was hit
------if not Collision Delay
---------set curJumps to numJumps

Zionviller

  • Posts: 2
Thanks! That fixed it perfectly!

tbcivilian

  • Posts: 7
You'll need a short delay to stop that from happening.  Make a new boolean attribute that you change when you jump, and use it to stop curJumps from changing just after jumping.  So if you made a boolean attribute called Collision Delay:

When Created
---set Collision Delay to false

Always
---if up was pressed and curJumps > 0
------set Y-speed to -40
------decrement curJumps by 1
------set Collision Delay to true
------do after 0.05 seconds
---------set Collision Delay to false

On Collision
---if bottom of actor1 was hit
------if not Collision Delay
---------set curJumps to numJumps

when trying to compile my test game I keep getting this message in the Log Viewer:
Events for 'Mambo' (169) - Unknown identifier
when I close the Log Viewer I see this part in the code highlighted in transparent red: [if <not> <Collision Delay>]