KevinnFtw

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?

Thanks,

Kevin

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.