How to detect the end of the bounce?

Hi,
I’m trying to find a trigger when the dude finished to bounce. Do you have an idea wich trigger I have to use ?
Here is my codepen : https://codepen.io/Tonio24100/pen/jdWwVv

Another question, I thought I could try with ‘container.body.speed’ === 0 but it didn’t work because speed = 13.8888 at the end.
Same question for ‘container.body.velocity.y’.
I think, it’s because of Gravity > 0 (in var config = {}). Am I right ?

I tried with other vars but no one gave me ‘0’ at the end of the bounce :
container.body.isMoving
container.body.moves
container.body.stopVelocityOnCollide
container.body.velocity.y

Thanks in advance,

Anthony

No idea ?
Is it possible to detect the end of the bounce ?

If you set a bounce value to a physics body (f.e. 0.5), the value will be unchanged. You can log this in your update() function with:

console.log(yourGameObject.body.bounce.x, yourGameObject.body.bounce.y);

What does change is the velocity. So you could check if the velocity is 0 (= your body is not moving anymore):

if (yourGameObject.body.velocity.y === 0) { do your stuff. }

Hi @Tonio24100,
This is one way:

if(container.body.deltaY() == 0 && container.body.onFloor()){
		// Your code
	  }

Regards.

1 Like

If you want to know exactly when the bounce happens you can listen to the worldbounds events.

But that will be firing continuously if the dude is walking across the bottom of the screen.

Thank you for your answer.
I changed setBounce(0.2) to setBounce(0) and the speed was 0, btu no more bounce…

Hi,
Thank you for your answer.
It solves my problem !

Hi
Thank you for your answer.
I will have a look to this way.