- Home /
How is it best to handle multiple layered colliders?
I am building a 2d spaceship game, where the ships have shields. I have the basic colliders set up, but now I am hitting a snag with shields. I'd like to have incoming objects strike the shields (if they are functioning and up), otherwise just strike the ship.
If a ship with shields up bumps into another ship with shields up, I want to have a collision. Currently, the first ship's shield will collide with the second ship, and prevent the second ship's shields from coming into contact with the first ship.
I think I might need to put a 2dRigid body on the ship shields (which is a child of the parent ship) in order to get the shields to respect each other. If I do that, I need to figure out how to turn off the rigid body if/when shields go down for a particular ship.
Does anyone have any suggestions of a better way to do this?
Answer by Pyrian · Sep 08, 2014 at 06:12 PM
Why don't you just set the shields to collide with each other?
I don't recommend adding a second Rigidbody2D to the same construct if they're never going to move independently. Rigidbodies are not constrained by the parentage, so you'd have to use another method to affix them. Further... I'm not sure what benefit you'd get.
I didn't think adding extra rigidbodies sounded like a good idea. I would think that this can be solved with just some colliders.
The circle collider2D don't seem to trigger each other, they only seem to be triggering when they collide with the ship's hull.
Other things I looked at:
I also checked to make sure that the layer that they were on was set respond to collisions with itself.
Both objects are created from the same prefab.
circle collider2D that represents the shield isn't set to be a trigger.
Don't know what else might be causing the missed collision.
Your answer