Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

2d look at unity

//this code will point the object to the mouse
Vector3 diff = Camera.main.ScreenToWorldPoint(Input.mousePosition) 
	- transform.position;
diff.Normalize();
 
float rot_z = Mathf.Atan2(diff.y, diff.x) * Mathf.Rad2Deg;
transform.rotation = Quaternion.Euler(0f, 0f, rot_z - 90);
 
PREVIOUS NEXT
Tagged: #unity
ADD COMMENT
Topic
Name
6+7 =