Spherecast and Trigger Capsule Collider

It looks like Physics.SphereCast ignores all colliders that are TRIGGERS while Raycast works properly with them.

I really need to use SphereCast with a collider that is also marked as trigger.

Does anyone knows if it is a bug or I’m missing something?

thanks.

Anyone can help me on this issue?

did you try to check the checkbox “Raycasts Hit Triggers” in project settings/physics and the layer collision matrix?

Im having the same issue and my Raycasts Hit Triggers flag is turned on. Is that by design, or is it a bug? My gut feel is it’s a bug.

I’ve just run into this issue. The Script Reference page for SphereCast mentions “sphere cast does not work against colliders configured as triggers” but doesn’t say why or suggest a workaround.

I’m thinking I could do several ray casts and get approximately the same result, but it is a little frustrating. Anyone know any more about this or know a better solution?

A bit late maybe, but it seems that there is a workaround:

  • create a new child object under your trigger object
  • add a collider to the child object that has the exact same shape as the trigger
  • create a new layer mask (let’s say “ColliderCast”) and set this layer mask on the child collider
  • go to the Edit → Project Settings → Physics Panel
  • disable all collisions on the “ColliderCast” layer mask.

Thus, nothing will collide with a “ColliderCast” object so this new collider shouldn’t change the behavior of other objects passing through.
However the sphereCast should collide with it, because it’s a collider and not a trigger (except if you filter the “ColliderCast” layer mask).
It seems to work for me.

Hope that helps. Peace :slight_smile:

This fixed it for me. Thank you.