I am wanting to filter triggers from a collider cast. What is the easiest way to check if a hit has a certain component on it or if the hit is a trigger? I'm working from the ECS Physics Samples. Here is my current code. Code (CSharp): MaxHitsCollector<ColliderCastHit> castCollector = new MaxHitsCollector<ColliderCastHit>(1.0f, ref castHits); ColliderCastInput castInput = new ColliderCastInput() { Collider = collider, Orientation = quaternion.identity, Start = origin, End = origin + rayDirection }; world.CastCollider(castInput, ref castCollector); for(int hitIndex = 0; hitIndex < castCollector.NumHits; hitIndex++) { var hit = castCollector.AllHits[hitIndex]; // Wanting to check if hit is a trigger here. } }
Not sure about the trigger, but for component checking you can use Code (CSharp): var entity = collisionWorld.Bodies[hit.RigidBodyIndex].Entity to extract the entity, which you can then use to check for a certain component (via HasComponent). There may be a more straightforward way, but this is the one I use currently.