unity rotate object to match normal code example
Example: unity rotate object to match normal
function Update () {
var hit : RaycastHit;
Debug.DrawRay (transform.position, -transform.up * 200, Color.red);
if (Physics.Raycast (transform.position, -transform.up, hit, 200)){
transform.up = hit.normal;
}
}