is there a way to set a detailed CollisionFilter layers for a RaycastInput ?
eg : belongsto Projectile , Collides with Players,Environment, Destructables …
// RayCast Input
RaycastInput input = new RaycastInput()
{
Start = projectileData.lastFramePosition,
End = translation.Value,
Filter = CollisionFilter.Default // Standard Filter
};
how can i get The Collider Layer from a RaycastHit ?
I don’t really read documentation so I can’t say if it exists there. I just read the source code.
As for your question about layers, CollidesWith is a mask field. 0xffffffff is just the hex code for everything.
If you only want layer 1 or 2 (and not layer 0) for example you could just use
CollidesWith = 1u << 1 | 1u << 2,
It’s very similar to regular LayerMasks
Except it’s a uint
// Bit shift the index of the layer (8) to get a bit mask
int layerMask = 1 << 8;
// This would cast rays only against colliders in layer 8.
// But instead we want to collide against everything except layer 8. The ~ operator does this, it inverts a bitmask.
layerMask = ~layerMask;