Jump Pad Bug?

gdt_s03_jump_pads

#1

I’ve noticed that the jump pads don’t always boost when the player lands on then from above. It seems that it has something to do with velocity, because it happens when falling from a great height, which includes falling back down to the jump pad after being boosted. In the image, a fall from the high large grass pad to the right of the bunny’s starting position, generally will not trigger the jump pad (The bunny will fall through to the terrain). Strangely, I have noticed that if I move in x while falling it will trigger. Thinking that x motion may be the trick, I tried moving in while falling after being boosted and the jump pad did not trigger. But a fall from the next large grass pad to the right will trigger the jump pad. I wonder if a race condition is occurring where the motion set by fall function is overriding the motion from the boost. The boost only happens once on enter and if the y velocity is overridden, then the player would be able to continue to occupy the same space as the jump pad without being boosted. That’s my theory. Has anyone else essen this? How did you work around it?

image


#2

Yep. That was it. I fixed this by adding a boost_override variable, initially set to false. In fall() I first check boost_override and set ti to false if it is true but don’t set the y motion.

func fall(delta):
	if boost_override:
		boost_override = false
	elif is_on_floor() or is_on_ceiling():
		motion.y = 0
	else:
		motion.y += GRAVITY * delta
		
	if position.y > world_limit:
		Global.GameState.end_game();

In boost, set the motion and set the boost_override to true

func boost():
	boost_override = true
	motion.y = JUMP_SPEED * JUMP_BOOST

Now my bunny will be boosted by a jump pad regardless of whether he fell onto it or moved onto it. This allows chaining of jump pads.