- Home /
Mesh Collider is Hiding Capsule Collider
Hi
I have run into a snag with my game that I cannot fix, I have a player object with a capsule collider attached to it, And I have an enemy which looks for the player.
The enemy Raycasts in a 130 degree cone, and if it hits the player (tag == "player") then the enemy starts chasing the player.
This part all works fine, until the player enters a building. The building is an asset I bought from turbosquid, I checked generate colliders on import. The mesh collider attached to the building works fine in terms of stopping objects walking through walls etc, but as soon as the enemy follows the player inside, the only collider it hits is the building, even if the player is stood right next to the enemy.
Does anyone have an idea why this would be happening? I have used debug.drawray and can see that the rayscasts are in the right place, it just seems like the mesh collider is intercepting every raycast.
You should try to visualize the contact point the ray gives you (Either by using OnDrawGizmos or by instantiating something in that place and Debug.Break()) That might help to see where the actual overlap occurs, which obviously does.