- Home /
Tree Colliders Not Working With Physics.CheckSphere / Capsule
I am having trouble getting the trees on my terrain that has "Create Tree Colliders" checked to work as functioning colliders. I am using Physics.CheckSphere now to determine if another collider is inside the position of an object I am trying to place only if there is nothing in the way. This works just fine for other objects that have colliders, but for some reason I can place the buildings right over any trees on my terrain. I know my Sphere is large enough because I have tried making the sphere cover the whole terrain, but Physics.CheckSphere still does not return true. I have tried a layermask for everything, just the terrain, just the default layer, and nothing, but none of them will get the trees to be in the way. All the buildings work just fine and can not be built on top of eachother, so I am not sure what the problem is. Also, I am using the trees that come in the resource package from the Unity website. Any help with this issue would be great, thanks!
Answer by jonas-echterhoff · Jan 26, 2010 at 04:04 PM
I just checked this, and I cannot replicate the behavior you are describing. CheckSphere does work with Tree Colliders. Are you sure the tree colliders are actually created? Does anything else collide with them? Tree colliders are only created when the prefab used as a tree prototype has a Capsule Collider component.
Hmm... maybe the trees I am using do not have a Capsule Collider in the prefab. They are just the trees that come with Unity and the Tree pack in the Resources from the Unity site. Oh, and nothing else collides with the trees but the check on the terrain is checked.
Yup, that is correct. The palm tree which comes with standard assets will not collide as is. $$anonymous$$ake a new prefab with that tree, and add a capsule collider. Use that as a tree prototype and everything should work as expected.
Answer by danielsig.du · Apr 06, 2010 at 05:57 PM
Hey I figured out what's wrong. You have to add a tree mesh to the stage, add a capsule collider component, then make it a new prefab. Click on your terrain and replace the trees with the new prefab :) voil!
Answer by danielsig.du · Apr 06, 2010 at 05:17 PM
this is happening to me also. I walk through trees :(
Answer by Mikey.du · Mar 29, 2011 at 09:40 AM
I add a capsule collider to the tree prefab then add it to the terrain and my unity crashes :(
Your answer
Follow this Question
Related Questions
Colliding with trees using mesh colliders 1 Answer
Billboard system 1 Answer
Tree collider doesn't work 0 Answers
Create a custom Collider? 4 Answers
Trying to use colliders on trees to interact with player 1 Answer