Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

unity look at 2d

Vector3 dir = target.position - transform.position;
 float angle = Mathf.Atan2(dir.y,dir.x) * Mathf.Rad2Deg;
 transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward);
Comment

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);
Comment

PREVIOUS NEXT
Code Example
Csharp :: c# convert datatable to csv 
Csharp :: dotnet.com 
Csharp :: return array in c# 
Csharp :: Prime number Upto n 
Csharp :: c# project 
Csharp :: c# enum to string 
Csharp :: string methods in c# 
Csharp :: javas 
Csharp :: c# stream 
Csharp :: copy file 
Csharp :: how to delete file in c# 
Csharp :: get index of item unity 
Csharp :: google tradutor 
Csharp :: how to make a enemy in unity 
Csharp :: unity ik nothing is happening 
Csharp :: winforms open multiple forms show one icon in taskabr 
Csharp :: syoutube 
Html :: html dollar symbol 
Html :: html5 template 
Html :: accept only image files upload html 
Html :: call link html 
Html :: upload only image input tag 
Html :: page dans un nouvelle onglet html 
Html :: html5 embed pdf base64 
Html :: conveert text to uppercase in input field 
Html :: regex to remove html tags python 
Html :: google web fonts open sans 
Html :: link javascript to html 
Html :: image src on error 
Html :: twig lower string 
ADD CONTENT
Topic
Content
Source link
Name
8+3 =