I am creating bullet hole decals on objects when I shoot them. This works on everything except for terrain where the decals will sometimes hover over the terrain and never have the correct rotation (always pointing up). Here's the code:
Vector3 hitPosition = new Vector3
{
x = collision.contacts[0].point.x,
y = collision.contacts[0].point.y,
z = collision.contacts[0].point.z
};
Quaternion rotation = Quaternion.FromToRotation(Vector3.up, collision.contacts[0].normal);
//Create the decal (ie: bullet hole)
GameObject decal = (GameObject)Instantiate(DecalPrefab, hitPosition, rotation);