Jump to content

Physics pass through


swervo
 Share

Recommended Posts

Hi,

 

This is my first post. I have done a search for this but I haven't found anything that specifically answers what feels like a basic question.

 

I'm developing my first game using phaser, it basically involves a character running along a rope and collecting things. The character jumps up and down and the objects come on at two different heights. It's a pretty basic game.

 

So, what I'd like to know is:

 

Is it possible to have physics bodies pass through one another. Specifically what I'd like is to be able to register the characters collision with the object but then have the object pass through the character and carry on off the screen.

 

By scanning these forums I discovered 'overlap' instead of 'collision' which has helped but the objects still don't pass through the character.

 

I'm aware that this is disobeying the laws of physics! But I had expected that there would be an easy way to do this - I've tried setting the body to null and a few other things but I can't find a solution that works.

 

Any help would be much appreciated.

Link to comment
Share on other sites

Thank-you. That looks like just what I'm looking for. One more question though:

 

Is it customary to debounce functions like this?

 

The processCallback still gets called multiple times for each collision (anywhere between 6 and 11 times) or is there a better technique to make sure it only gets called once per collision?

Link to comment
Share on other sites

The processCallback (and collideCallback) will be called once per frame providing that 'collide' is only called once in your update loop, for as long as the objects overlap or collide.

 

So if it takes 6 frames to fully separate the sprites (or for them to no longer be overlapping) then it'll be called 6 times. If they are are separated immediately after 1 frame, it'll get called once.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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