x


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!

more ▼

asked Dec 28 '09 at 11:15 PM

Brian 1 gravatar image

Brian 1
49 2 2 7

(comments are locked)
10|3000 characters needed characters left

4 answers: sort voted first

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.

more ▼

answered Jan 26 '10 at 04:04 PM

jonas echterhoff gravatar image

jonas echterhoff ♦♦
9.7k 7 23 103

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.

Jan 28 '10 at 12:09 AM Brian 1

Yup, that is correct. The palm tree which comes with standard assets will not collide as is. Make a new prefab with that tree, and add a capsule collider. Use that as a tree prototype and everything should work as expected.

Jan 28 '10 at 09:23 AM jonas echterhoff ♦♦
(comments are locked)
10|3000 characters needed characters left

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!

more ▼

answered Apr 06 '10 at 05:57 PM

danielsig gravatar image

danielsig
11 1

Thanks! I don't like walking through trees. :)

Aug 02 '10 at 09:51 PM BinaryCaveman
(comments are locked)
10|3000 characters needed characters left

I add a capsule collider to the tree prefab then add it to the terrain and my unity crashes :(

more ▼

answered Mar 29 '11 at 09:40 AM

Mikey gravatar image

Mikey
1

(comments are locked)
10|3000 characters needed characters left

this is happening to me also. I walk through trees :(

more ▼

answered Apr 06 '10 at 05:17 PM

danielsig gravatar image

danielsig
11 1

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1869
x1690
x1470
x228

asked: Dec 28 '09 at 11:15 PM

Seen: 3762 times

Last Updated: Jan 26 '10 at 04:05 PM