How can i add decals dynamically to a 3d model OnCollisionEnter?
I know i’m supposed to use CommandBuffers DrawMash.
But how can i know what rotation should i give each decal so it would look ok on the model at the point of collision?
How can i add decals dynamically to a 3d model OnCollisionEnter?
I know i’m supposed to use CommandBuffers DrawMash.
But how can i know what rotation should i give each decal so it would look ok on the model at the point of collision?
OnCollisionEnter returns at Collision which in turn contains an array of contacts, each of which in turn has a normal variable (Vector3). Use this Vector3 to rotate the decal object (assuming Decal is a gameobject and it’s transform.up goes away from the decal plane):
decal.transform.rotation = Quaternion.FromToRotation(decal.transform.up, hit.normal) * decal.transform.rotation;