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?
Look here: Unity - Scripting API: Collider.OnCollisionEnter(Collision)
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);
}
}
}