Hello,
I have seen that you can setup a Ignore betweens colliders
And between layers:
But, could you set up a ignore between a collider and a layer?
Thank you.
Hello,
I have seen that you can setup a Ignore betweens colliders
And between layers:
But, could you set up a ignore between a collider and a layer?
Thank you.
That’s what IgnoreLayerCollision does. It’s not “between layers” but more, a collider on one layer won’t collide with a collider on the other layer.
Hello @MelvMay ,
I think I did not explain myself,
I want that a specific particular collider does not collide with an entire layer.
Imagine Layer A and Layer B.
I want that all the colliders of A collides with B.
But, I want that a specific collider of A, because of an event, stop colliding with all the layer B, but the other colliders of layer A still collides with Layer B
private void OnTriggerEnter(Collider c)
{
if (Something(c))
{
Physics.IgnoreCollisionColliderAndLayer(c, LayerB)
}
}
Unfortunately we don’t support that yet but it would be possible to implement it and we already do have this on a planning board card, just at a low priority. I know this doesn’t help.
The only other way to do this is to use a Kinematic body-type with full kinematic contacts set. That way you explicitly control what happens but you also obviously need to control the collision reactions too.
I suggest that you can create a Layer C which do not collide with Layer B.
When you want to ignore the collision between a specific collider and Layer B, you can temporarily switch its layer to Layer C.
This feature would be useful. I know we can create a new layer L1 for a specific object and then say that L1 objects should be masked from L2 objects, but this involves defining a new layer just for the specific object, which is not hard but it’s hugely wasteful when we have a mere 30 or so layers to play with. It’s possible that a game would have more than 32 kinds of objects, so having a way to tell specific object’s to ignore a certain layer without having to make a special layer for it would be very very useful.
Any updates? I really need this feature in Physics2D, too.
I hope this gets added as well, my world destruction system could get a lot simpler with it. Right now I just change the destroyed object’s layer when it gets destroyed… but this causes issues if you want to destroy an object already in a layer without changing it’s layer.
Bump. Any news on that? This is causing some tasteless implementations. I’d like an object’s collider (and only that one) to decide which layers to ignore / unignore.
I really need that feature rn. Trying to implement some portal system and i need to disable all collisions for the object passing through portal so that it can get through it even if there’s a wall behind. Ignoring collision for the whole layer would lead to other objects of the same layer just falling through the ground while this object traverses the portal. Dunno if i’ll find a suitable workaround for that…
It’s somewhat impressive that this hasn’t been added yet. It seems like a somewhat simple feature to add. Would be great to finally get this in!
Would be useful for sure, please keep us updated.
Hi MelvMay, This has been 4 years since you posted this. Has it still not come up? Personally I can’t comprehend how this is a low priority issue tbh. An object should be able to choose which layers it can collide with. To me at least, if you build a rather big 2d game, it is going to cause a huge headache and spaghetti code without this, because:
a) You globally make layers ignore each other. If you do this, you can’t customise your objects and you will need maybe hundreds of layers. or
b) Every object in a scene has to keep a reference to every other object it wants to ignore/allow collisions which is one of the most horrible anti-patterns in software design.
c) You happily let everything collide with everything else and decide your action on trigger / collide events. Which has its own issues with bloated code, objects with rigidbody and again, bad design, possibly performance.
I’m wasting considerable amount of time in my game just because I am forced to work around this.
Some sort of a function like Collider.Ignorelayers(Layermask) or Gameobject.Ignorelayers(Layermask) should be enough.
I’d love to hear from you. Thanks.
Hola ![]()
I second the guys above me, this would be quite useful, especially since layers are not only used for physics objects and are of a limited quantity.
This is really needed asap, since currently unity mixes rendering layers and physics layers, wich makes it terrible in order to work properly with these, if unity were using the physics layers systems as DOTS physics cathegories this would be awesome
Maybe you could ad this layering system and call it Physics layers 2.0, so people can switch and decide which one to use in their project, so you would be able to chose the “Belongs to / Collides with” by each collider, offerinh an incredible flexibility and finally decoupling it from rendering…
Already landing in 2022.2 amongst many other things: x.com
It is just for 20 Rigidbodies or it will work also on 3D rigidbodies? we really need it for 3D
The 2D physics and 3D physics teams are seperate.
I know work on 3D physics here was being done, let me check on its progress with respect to 2022.2.
Nice, let us know if its confirmed please!
I can see the PR but I don’t think it’s landed in the 2022.2 alpha yet but it was just confirmed that it should land in 2022.2 (in Review/QV but not landed yet). It has the same include/exclude properties on Rigidbody and ArticulationBody too.
I cannot link to any API docs until it lands though as they are published shortly after that but they work in the same way as the 2D equivalent.