- Home /
How to check which terrain the object is over?
Hi,
I want to check which terrain my object is currently over, to aid in performance improvements. I have +- 100 terrains in my scene with all the terrian colliders turned off.
I see this unity answer http://answers.unity3d.com/questions/613257/best-way-to-check-which-terrain-im-over.html but that needs the terrain collider already enabled.
Is there a way to test which terrain the gameobject is on then enable the terrain collider for that terrain using a Javascript?
Any info would be much appreciated.
Thanks, Kim
Just check the objects position, and then the terrains position. If the object is in the terrain position activate it, else, deactivate it. Use Vector3.Distance to find the distance.
Answer by hkessock · Mar 27, 2014 at 07:31 PM
I would try simply checking my object's position relative to the Mesh renderer's bounding box for the terrain.
Your answer

Follow this Question
Related Questions
How to perform intersection test between two colliders? 2 Answers
collider trigger or scripting 3 Answers
Does it cost in performance if I have mesh colliders without a mesh attached? 1 Answer
Is it slow to move a rigidbody's child/compound collider? 1 Answer
Random Performance Spikes due to Physics.Processing in a static scene. 1 Answer