1

I have made a model of a building in blender and imported the .blend it to Unity. There are multiple objects within this building model including windows, a door and floors/ceilings. I have added mesh colliders for each individual object and marked them as static for baked lighting. After baking I unchecked the door as static so the collider could swing open and closed with the animation.

The problem is that when I am on the outside of the building and the door is open, if I try to shoot into the building through the space in the door hole, the raycast for the shot stops at where the door was. For the object of the building such as walls and the door itself, they are tagged so that if the raycast hits it, it plays a sound and creates a spark particle. When shooting at the seemingly empty space when the door is opened, there is no sound or particle effect. The ray just seems to stop and disappear where the door used to be closed. It is also odd that when I am inside the building shooting outside through the same open door space, the raycast actually does travel past and plays the sound and particle effect at objects outside. When I delete the door object, the same thing happens. And when I delete the building itself, the same effect happens for where the walls and windows used to be.

Here's what it looks like - from outside shooting in outside

From inside shooting out - inside

I'm using Unity 5.6.1f1 and C# for scripts.

vvvvv
  • 25,404
  • 19
  • 49
  • 81
  • You can remove objects from raycast with bitmask. See the duplicated question and answer for how to do that. Just put the building parts in a layer then use the appropriate bitwise to filter these objects. – Programmer Jun 07 '17 at 21:03
  • Doesn't sound like a duplicate to me. The issue at hand seems not to be related to layer masks. Seems there might be some issue with static colliders not being updated correctly/as expected by OP – Thomas Hilbert Jun 08 '17 at 21:48
  • See https://docs.unity3d.com/Manual/CollidersOverview.html under "Static Colliders". Probably adding a Rigidbody to your door might solve the issue, though I am still confused why the static collision mesh is not updated, as you stated you unchecked "Static" on that door. Maybe reimport the scene, too, but I'm only guessing here. – Thomas Hilbert Jun 08 '17 at 21:52

0 Answers0