- Home /
Question by
Saint-Pasteque · Jun 27, 2020 at 11:15 AM ·
raycasttransformmouserotation axistransform.forward
How edit transform.forward value ?
Hi, i want to set the value of transform.forward the Z axis value of object hit by raycast to make something like that for exemple :
Here's my code
private void Update()
{
RaycastHit hit;
transform.Rotate(Vector3.up * mouse_h);
if(Physics.Raycast(transform.position,-transform.up, out hit, 10000f)){
transform.forward = XXX;
print($"hit : {hit.transform.name}");
}
Debug.DrawRay(transform.position,-transform.up * 500,Color.red);
}
}
Comment
I'm not really sure what you are asking. Are you trying to rotate the object once the raycast hits an object?