- Home /
Sphere Collider with Terrain
I am trying to get my gameobject to move 180 degrees if it walking into a wall, or a tree (any terrain). I am using the onTriggerStay function, but it is not registering.
Here is the code snippet for the detection.
void OnTriggerStay (Collider hit) { if (hit.tag == "Terrain") { Debug.Log ("Not Touching"); wallhit = true; } else { wallhit = false; } }
For some reason it is not triggering when the game object does walk into the wall. Any help please?!
I have made sure that the istrigger is checked for the sphere collider, and I have made sure that the tag for the terrain is called "Terrain".
Are your walls tagged as 'Terrain', which would be a bit strange? Did you use a tree prefab that has a proper collider on it?
Your answer
Follow this Question
Related Questions
unity 4.0 terrain collider issue 1 Answer
Player falling through Terrain collider 0 Answers
Terrain rotating on collision,Terrain rotates on collision 0 Answers
Capsule collider going through terrain collider 1 Answer
Car falls through terrain 2 Answers