Jump to content

Multiple colliders in one object


Goodlike
 Share

Recommended Posts

Hello to all!

I've been looking for really long and Phaser examples seems to be not enough for my problem with multiple collisions and detection in P2 system, which seems to be good so far but I stuck at the 3 important things. :D


1. How to create those multiple collision shapes?
I have one object to whom I add properities like game, inputs, sprite and some of physics attributes. But how to apply two separated colliders?

I tried to make big object and apply there two smaller parts (applying again sprites, inputs, physics) to make them work good, but code grown into enormous size, which I deleted and now I'm thinking if there is simplier way. Do you know any solution for such situations or another way?

At first I followed by https://www.codeandweb.com/physicseditor/tutorials/phaser-p2-physics-example-tutorial 
and I'm thinking if making at least two, separated shapes in JSON file like there:
https://github.com/CodeAndWeb/phaser-p2-physics-example/blob/master/07-scoring/assets/sprite_physics.json
will work? Especially when it's connected with next question:

2. How to detect which shape was colldied?
I mean for example, two shapes - one wraps head, second - body. It's possible to detect separatedly if only head or only body was touched by another object?

3. How to get a names or whose object were collided? I mean a situation where I have 4 objects whose collide each others and I need to retrieve which one is in touch with another.

I hope those questions are so so to understand, because I really don't have any idea in what way face with them. Can I count for your support with thoughts, articles, or another helpful materials, which may help me to solve above's struggles? :) 

Thank you in advance!

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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