I’m making a game where you graffiti on walls. My current code aligns the instantiated decal to the normal of the object being sprayed on, however often it appears upside-down or sideways, so I want to make it align to the ground so it is facing ‘up’. I also want to add functionality to rotate the graffiti around the normal by moving the mouse left and right, but my priority is making it appear the right way up.
function Spray()
{
var hit: RaycastHit;
if (Physics.Raycast(transform.position, transform.forward, hit))
Debug.DrawLine(transform.position,hit.point,Color.red,1.0f);
{
if (hit.transform.tag == "Surface")
{
var rot = Quaternion.FromToRotation(Vector3.up, hit.normal);
gernz = Instantiate(tagged,hit.point+(hit.normal*0.0001),rot);
Debug.Log("hehe");
}
}
}