LayerCollisionMatrix: a,b = true ----- b,a = false possible?

Hello fellow developers

Is it possible to have layer “projectile” ignore layer “radar”.
But at the same time have layer “radar” register collision with layer “projectile” ?

514752--18293--$collision-Matrix.jpg

// Object Setup:
projectile = 1 rigidbody, 1 trigger collider

ship = 1 rigidbody, 1 collider
–>subobject radar = 1 code generated trigger collider

I Tried with the default project settings, as well as in code with:
Physics.IgnoreLayerCollision(LayerMask.NameToLayer(“Projectile”), LayerMask.NameToLayer(“Radar”));

If not possible no problem.

Thanks for your time reading.
It’s appreciated

Stop Here: If you don’t want to hear me talk about my Plan B
(probally using Physics.OverlapSphere and casting that once each second)

But I really liked the onTriggerEnter and onTriggerExit events which populate my Target List.
That Way I Could have each ship have his own TargetController
(probally not very performant, but wanted to try it anyway and see how it goes)

I believe it is not possible, since that representation doesn’t say which one of the layers is first. So, the logic assumption is collisions are registered by objects in both layers. Your problem should be related to rigidbody traveling at high speed, I’ve seen quite a few discussions on the forum about this.

So the Collision Matrix is Bi Directional:
Layer “A” ignores Layer “B”
== implies ==
Layer “B” ignores Layer “A”.

And there is no way of having a Directional Collision Matrix:
Layer “A” ignore Layer “B”
=== At the same time have ===
Layer “B” not ignore Layer “A”

Thanks

IgnoreCollision is still in the api, so you could still accomplish it on a per object basis.

Well the problem with that would be that my fired rockets would ignore my radar but it would still collide and explode with all the enemy radars.

Unless I iterate over the target list first and ignore each and every radar instance.
And If I get unlucky a new enemy ship will fly just outside my radar range, but the missile that was shoot will hit his radar range.
So that solution would not work.

No biggy, I will at the moment just ignore missiles and I am probally going to use a hybrid approach, have the radar for tracking geometry(Ships, asteroids, stations) and use a Physics.OverlappingSphere for the Missile Detection.

Or just ignore the radar collider inside of the ontrigger from the Missile.

Or have the Shooter tell the Target that it fired a Missile.

I will try some different approaches and see which fit’s the best.

I Just want to make sure that my understanding of the “LayerCollisionMatrix” is correct:
That it’s indeed Bidirectional:
Ignore Missile Layer, Radar Layer
will make the Missile Layer ignore the Radar Layer
as well as make the Radar Layer ignore the Missile Layer

And that there is no way of making the Missile Layer just ignore the Radar Layer
But still have the Radar Layer trigger collision with the Missile Layer

Thanks for all the Answers.

That’s the way you would do things back in Unity 2.6. There are even a few collision managers floating about that you can look for on the wiki. Since you are instancing rockets, you could iterate at the point.

The trick for good performance is to keep a running array of your ‘radars’ or whatever, instead of searching for them at runtime by their tag.