Jump to content

How can I apply arcade.body.bounce to a immovable objetc?


totallybueno
 Share

Recommended Posts

Hi there, I have a basic game where the player jumps from a building and must fall into different platforms during the falling to avoid crashing directly with the  ground.

The thing is that those platforms should have some bounce, I mean, when the player falls into those platforms, it should rebound like if they were some kind of elastic stuff... the problem is that as the platform has body.immovable = true it seems that body.bounce is not working at all, and I can´t apply body.bounce to the player because he should rebound only on those platforms, not on every single object.

 

I have the world with a global gravity and those platforms immovable and with their gravity.y = -that global gravity, is this the best way to to this? Any other way to create purely static objects?

Link to comment
Share on other sites

In Arcade Physics immovable means it can't be moved by collisions. So no bounce. ;)

For platforms, remove immovable and gravity and use instead:

platforms.setAll('body.allowGravity', false);
platforms.setAll('body.bounce.y', 0.5);

But if you want an elastic effect that returns the platform into place, you should lock all movement and use a tween instead of body.bounce:

platforms.setAll('body.moves', false);

 

Link to comment
Share on other sites

On 4/8/2017 at 5:25 PM, samme said:

In Arcade Physics immovable means it can't be moved by collisions. So no bounce. ;)

For platforms, remove immovable and gravity and use instead:


platforms.setAll('body.allowGravity', false);
platforms.setAll('body.bounce.y', 0.5);

But if you want an elastic effect that returns the platform into place, you should lock all movement and use a tween instead of body.bounce:


platforms.setAll('body.moves', false);

 

@samme thanks, that´s what I needed! The bounce is now working properly, even with a bouce.y = 1 I can see a tiny tiny movement, I guess something else is affecting this, but anyway, the platform thing is working and with a player.body.velocity.y =-500 y can make that rebound effect... so, fixed, thanks for your help :)

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...