- Home /
Trying to use colliders on trees to interact with player
I'm trying to use colliders on trees/rocks to stop the player when they run up against the tree/rock. I've tried placing a collider on the tree, but I'm not sure how to stop the player.
EDIT: I'm using a first person controller with all defaults. I'm using terrain tree placement for all rocks and trees.
Could do with a bit more info on how your player is set up, and more info about your tree setup too(are you using the terrain tree placement or not?)... Thanks
Answer by MrSoad · Nov 13, 2014 at 02:05 AM
Are you using the terrain Asset trees?
If so then :
1) Drag the tree you want to use into the scene, from the terrain assets folder(do not place via the tree paint tool!).
2) Create a prefab in the same folder you got the tree from. Give this prefab an appropriate name.
3) Add a collider to the tree in your scene(the one that you placed in 1)
4) When you have the collider how you want it, drag this tree(from the hierarchy window) onto the new prefab that you made.
5) Go into your terrain editor and add your new new tree prefab to it.
6) Paint your new trees on the scene and they should all have colliders and the player should stop correctly.
But there's no way to apply the prefab to existing trees in the scene?
If you have used the terrain asset trees then not that I know of, these are not normal prefabs, the are 3D model files, you cannot amend them with a collider and save them, you have to amend them then save them as a new prefab, and start from scratch in your terrain editor painting the new collider versions using the prefabs you make.
Do the same steps apply for other terrain assets like rocks?
Yes they do, anything that is just a 3D model file (the blue cube with the little page icon over it) will have to be altered and saved by this method if you want it to have a collider using the terrain editor :(
Thanks so much for your help! I'll go through and replace the trees and rocks, but that shouldn't take too long.