I’m making a plattform game, and for the collisions, i group up all the objects that are part of the plattforms and set them in a same layer
public LayerMask collisionMask;
so the player collides with every object in that layer.
i was thinking in setting a button to change that layer so the player can get through the plattforms and collides with others plattforms set in another layer, is there any way that i can do this?
Just set each group of platforms (colliders) to separated layer (in the inspector) and than in the button use
Physics2D.IgnoreLayerCollision(1, 2, true); //disable collision detection
or
Physics2D.IgnoreLayerCollision(1, 2, false); //enable collision detection
where “1” will be the layer of your player collider and “2” or any other number will be the layer of the group. You can enable or disable collision with multiple layers at the same time. The numbers you get from layer editor. Read more here http://docs.unity3d.com/ScriptReference/Physics2D.IgnoreLayerCollision.html