- Home /
Terrain tree colliders as triggers
What's the best way to create colliders for trees that act as triggers? I know how to make collision colliders for trees, but not trigger ones. We have a lot of trees in our game and we need to make them all triggers, any suggestions?
This tree colliders thing is extremely frustrating is there no workaround that will work? Are there plans to fix this in the future?
Answer by Chris D · Jun 29, 2011 at 04:32 PM
Well, to set a collider as a trigger, there's a property, detailed here, called isTrigger. Just set it to true in script or you can check the box in the inspector (under the collider's entry).
This will cause other colliders to pass through your trees with no physical collision. If you're just looking for a way to see when a tree is collided with while maintaining it's solidity, just use the appropriate version of onCollision (first three results).
Thanks fo the response ChrisD, unfortunately that doesn't seem to be the problem. The crux of it seems to be to create a "terrain tree" that can be painted onto the terrain you need to:
place your tree model into the scene
assign a capsule collider to that tree
adjust the collider to fit the tree as you want it to fit
create a prefab from your tree+collider object
in the terrain editor -> tree painting menu add a tree and use your tree+collider prefab as the tree model.
from what I can gather when you turn a prefab with a trigger collider into a terrain tree the trigger collider no longer works.
That...really is strange. I suppose you could always loop through a list of your trees afterwards and set isTrigger to true, but that seems like a hacky work-around...
That's what I thought too. So wait, have you had any success with using terrain trees with trigger colliders? Do you have any suggestions on how I could get them to work.
Here's a run-down of what I'm trying to accomplish with terrain trees as a trigger:
Prefabs/Assets:
I have a particle effect prefab that has a leaf texture looks like falling leaves.
Tree with collider set to trigger.
player race car.
Interactive Actions:
WHEN a race car collides with a tree THEN A. Slow down car (but do not stop it!) B. spawn leaf particle prefab on tree.
Currently I'm adding sphere/capsule colliders by hand to all the trees in a scene to trigger this action, but if I'm going to make multiple levels with any kind of efficiency I'm going to need another way.
Again I can get the terrain tree collision colliders to work fine... but that makes trees that completely stop the player. I just want trees to slow down the player.
Thanks again for you assistance!
In your terrain, is the Generate Tree Colliders box checked? If so, it's probably over-writing your custom collider/trigger.
Answer by manno · Sep 30, 2011 at 06:33 PM
This tree colliders thing is extremely frustrating is there no workaround that will work? Are there plans to fix this in the future?
If I set the terrain collider to a separate layer from the player collider the player collider still is impacted by the tree colliders! Why wont this work? When will it get fixed?