Filtering

Is it possible to filter collisions by ID without incurring a call to OnTrigger/Collision?

Like say:

only objects with ID 1 collide with each other, ignore all other ids
only objects with ID 2 collide with each other, ignore al other ids

I know people are handling this inside of OnTrigger/Collision - I’m wondering if it’s possible without the overhead incurre by the function call

You have two ways for achieving this:

1 Like

thanks!

two questions

  1. There is a limit of 24 user layers? what if I need more?

  2. can a layer be set or changed during run time through the scripting API?

for 2) I meant - can I set or change an object’s layer value during runtime through the scripting api?

  1. Layers are limited by Unity, nothing we can do here. You may use some of the lower layers as well if they fit in your game’s logic. For example, I’ve used the layer “Water” for “non-playable ground”.

  2. Yes, layers may be changed anytime from scripting with immediate effect. GameObject.layer

1 Like

many thanks :slight_smile:

1 Like