- Home /
SphereCasting ignores the mesh collider?
I'm trying to detect if the player is next to the "wall" of my level. My player has a box collider, and the level has a mesh collider set as a trigger. Works fine, no problems, player cannot pass through the wall.
I play an animation every time the player moves, but I don't want to play it if they're going to collide with the wall so I'm trying to test for it. First I tried SweepTest, it returns no collision. I've tried Physics.CapsuleCast and now I'm trying Physics.SphereCast and I'm getting no collision, it's as though it doesn't see the mesh collider. Is it a meshcollider limitation, a problem with the mesh being a trigger? Do I need to do something with layers for this to work?
I even tried:
if (Physics.SphereCast(rigidbody.position, 2.0f, movementDirection, out hit, Mathf.Infinity))
and there was no response, so I don't think this is a distance or radius problem. (movementDirection in this case is Vector3.down)
If you make the mesh collider a non-trigger does it return properly? It sounds like it is probably an issue with trigger interactions. I don't think that physics casting can tunnel through colliders, but you could also try putting some invisible box colliders around your level to cast against.
I've come to the same conclusion: my SphereCast works fine with SphereColliders but ignores $$anonymous$$eshColliders. Have you come across a workaround in the last six monthts?
Your answer

Follow this Question
Related Questions
2D 360 degress platformer example needed 0 Answers
Moving and SweepTesting a kinematic Rigidbody multiple times within a single FixedUpdate() call 0 Answers
How does Totally Accurate Battle Simulator's physics and animations work? 0 Answers
Physics gravity appears very weak 2 Answers
Bullet getting repelled when coming closer to it's spawn point. 1 Answer