Phaser one-sided overlap detection?

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?



Share this post

Link to post
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 :)

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.