Box Collider on terrain trees activate far from the actual collider

The trees are prefabs but are placed as terrain trees. There is a space ship that explodes when hits the tree. The moment I got the screenshot is the moment that the ship collides with terrain (the tree). However, there is a giant gap between the tree and the ship and as you can see in the prefab, the colliders are not there yet.

This issue does not happen when the tree is placed as a prefab directly in the scene.
Screenshot 2023-03-15 at 12.52.44 AM

Hi,

Have you already tried to add Debug.Logs to your code to see what is going on during runtime? For example, how do you know that the invisible ship collider collided with the invisible tree collider?

Yes I did. It collides with the terrain (since the tree is a part of the terrain not an standalone object).

It collides with the terrain (since the tree is a part of the terrain not an standalone object).

Is this an assumption or did you verify that with a Debug.Log? I’m asking because your settings could be “perfect” but we never know if something else messes around with things in Unity at runtime. Never rely on “this makes sense, therefore it must be working and I don’t need to check it”.

Also, there is a chance that the physics simulation moves the ships rigidbody and collider. The components are invisible. For this reason, we cannot look at the visualised mesh to determine whether a collision happened or not.

Try to figure out how far the tree colliders are away and if there is a pattern like “the giant gap between the tree and the ship is always the same”.

If you use an older version of Unity, consider updating.

When I turn off the collider on the prefab, the collision does not happen anymore. It’s not an assumption it is verified. I used physics debug tool in unity editor and unfortuately it does not show collider for terrain trees. I am using 2021.3.16f.

Could you please describe the problem again that you’d like to solve? What does work? What does not work (yet)? Maybe I misunderstood your first post.

Privacy & Terms