- Home /
 
 
               Question by 
               RealFighter64 · Jun 21, 2015 at 11:37 AM · 
                collisionterrainterraincollider  
              
 
              Terrain - Detect collision coordinates?
Hi, I'm making a game where as things collide with the ground (a Terrain object) the floor is coloured. I have made a class where I can paint specific coordinates on the Terrain, however I don't know how to get the coordinates where the object hits the Terrain. Does anyone know a way to do this?
               Comment
              
 
               
              I'm a little confused, are you coloring the entire terrain object, or just part of it?
I'm only painting the general area where the object collides.
Answer by lugduweb · Jun 22, 2015 at 07:31 AM
Look here: http://docs.unity3d.com/ScriptReference/Collider.OnCollisionEnter.html The contact point is the thing you are looking for.
 using UnityEngine;
 using System.Collections;
 
 public class ExampleClass : MonoBehaviour {
     
     
     void OnCollisionEnter(Collision collision) {
         foreach (ContactPoint contact in collision.contacts) {
             Debug.DrawRay(contact.point, contact.normal, Color.white);
         }
         
         
     }
 }
 
              Your answer