Jump to content

overlapping sprites within saem group


mm
 Share

Recommended Posts

Hello, I'm having issues overlaping sprites that are in the same group, basically what I want to do is change the sprites position when they collide with another sprite from the same group, but when applying this.physics.arcade.overlap(group, group, function, null, this)  seems like the sprites are colliding with itself and always calling the function.

Am I on the right way path of doing what I want or is a better way to do it?

Thanks in advance for any help. 

Link to comment
Share on other sites

That's the primary difference between arcade.overlap and arcade.collide: overlap tells you that the sprites are "touching" but won't do anything about it. collide tells you that they're touching then moves each one to separate it from the thing it collided with.

Sounds like you want collide, not overlap.

Link to comment
Share on other sites

I did a work-around to make it work, if anyone runs into this issue here's my solution:

When comparing overlapping between the same group the objects itself count as overlap so any function will be called always, so, set into that function a validator for the objects which are colliding so it only runs when it meets the case you need; also I set some extra validators on the update so the function won't be called every frame but this last will depend on what you are looking to achieve

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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