Jump to content

Phaser one-sided overlap detection?


KevinnFtw
 Share

Recommended Posts

Hi guys,

At the moment I'm having some issues detecting which sprite is overlapping another sprite.

The overlap function works fine, but I would like to know which of the 2 sprites goes over the other sprite.

I only want to execute a certain function if sprite A walks over sprite B, and not if sprite B walks over sprite A.

Is there any way I could check this inside of the overlap function?

Thanks,

Kevin

Link to comment
Share on other sites

Could you not check the current velocities of the items to determine which one was moving at the time? What you're trying to detect presumably is which one is the instigator of the collision - and that problem becomes very difficult to solve if both are moving and neither have a clearly defined 'source' of motion. Maybe you need a flag on your sprites to determine if they're 'walking' or not. Then in the event of a collision, check the flag for both sprites - if one is walking and one is not, then the walking sprite is the instigator, and so do something, otherwise ignore the collision.

 

Like I say this can be quite a difficult problem to solve; and not from a programming perspective but just in general. It certainly forms the basis of automotive insurance :)

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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