- Home /
How can I get two capsule colliders on the same tree prefab?
I am trying to make my trees so they cannot be clipped through at all, but I still want the player to "touch" the tree. I figured out how to make the player unable to move through the trunk of the tree, but I cannot make it so they collide with the branches. Now, if I make it so they cannot collide with the branches first, the player is able to move through the trunk without a problem. The tree has the colliders for both, but only the one I added first actually works. Is there a way to make it so both works or even better yet, a totally different and more realistic way of going about this?
Answer by SkaredCreations · Dec 18, 2014 at 10:58 PM
Create new objects with collider within the tree hierarchy, so you'll have as many colliders as you like. Or eventually you could use Mesh Collider attached to objects that have a mesh renderer.
So I guess a follow up with that: How can I make those objects invisible?
If it's an empty gameobject with just a collider it will be invisible
@OneWithTheCore: You either have to:
Add an empty gameobject as child and manually add a capsule collider to that empty gameobject
Add a capsule object from the gameobject menu and remove the $$anonymous$$eshRenderer and $$anonymous$$eshFilter as those will render a capsule mesh object which you don't want.
Hi @Bunny83 I redid a tree prefab in this way and applied it to the terrain object. I had the same result as before, the second collider did not register...
Can you tell me where I'm going wrong on this, thanks :)
Answer by MrSoad · Dec 18, 2014 at 11:10 PM
I've just done a test in a scene of mine and what you say in your post seems to be true. If I create a tree prefab with two colliders and place this on my scene then they both work as expected. If I then add this prefab to the terrain trees and paint one or more onto my terrain only one of the two colliders on each tree painted works(the first one added). Maybe this is something deliberate about how the terrain system works, I know that the mesh objects that are used within it have to be one whole mesh or you get errors there too...
Edit : Note that you did not mention terrains in your post, so it is my best guess that this is the problem that you are talking about. If it were not for this then what @SkaredCreations says is absolutely right.
Edit 2 : I would think that using Mesh Colliders on trees is probably not a great idea.
I am sorry that I was not clear. They are trees for the terrain. What am I supposed to do since they are part of the terrain?
@OneWithTheCore: Hmm i never really used the terrain engine so it might be possible that you can't add more than one collider for a tree prefab.
This might be helpful. Since the trees are usually fix in place, generating an additional collider prefab for each tree instance should be quite simple.
Just tried out a convex mesh collider, the terrain placed trees ignore it completely, can walk right through it... :(
Your answer
Follow this Question
Related Questions
How do I prevent my 2D Sprite from clipping into my 3D Environment 0 Answers
Collide with trees? 1 Answer
Tree billboards clipping into terrain 1 Answer
MouseOrbitImproved camera distance seemingly inverted 1 Answer
Player jumping from wall sometimes jump even when not collided with other wall 0 Answers