Jump to content

Collision and movement


casarock
 Share

Recommended Posts

Hi,

 

I have two objects. A Player-Sprite and a Platform-Sprite in a collection. My Player-Sprite has no y-velocity. The Platform-Sprite at the collection has a velocity of -50 (from bottom to top). 

 

If my Player collides with a platform the platform stops moving immediately. But I want the player to move up with the platform. I've tried several properties like immovable=false, mass of 0 etc.

 

How, if possible, could I achieve this? Later I want to have gravity for player sprite. Is this possible? Or do I have to rethink my approach without using physics?

 

 

Link to comment
Share on other sites

Instead of collide, use overlap

this.game.physics.collide(this.platforms, this.player, this.collideCallback, null, this);

just change the function called, the parameters and return value are the same.

this.game.physics.overlap(this.platforms, this.player, this.collideCallback, null, this);

"Unlike collide the objects are NOT automatically separated or have any physics applied"

Link to comment
Share on other sites

Hi,

 

I want to have the player on top of the platforms, moving upwards with the same speed as a platform. when the player is outside the platform it show have a gravity of about 250. With overlap the detection is not good enough, as the player sometimes is "inside" a platform.

 

Seems like I have to rewrite it and not using velocity/gravity. What did I misunderstood?

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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