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 :: unity raycast all layers except one 
Csharp :: bin/bash bad interpreter 
Csharp :: get path c# 
Csharp :: c# randomize a list 
Csharp :: c# change label value into int 
Csharp :: unity disable cursor 
Csharp :: scenemanager c# 
Csharp :: c# run c# code from string 
Csharp :: c# convert seconds to hours minutes seconds 
Csharp :: c# list all files in a directory and subdirectory 
Csharp :: Unity rotate player to mouse point slowly 
Csharp :: unity know when gameobject presed 
Csharp :: c# System.Resources.MissingManifestResourceException error 
Csharp :: delay in unity 
Csharp :: untiy delet ke 
Csharp :: how to choose a random child in a gameobject unuity 
Csharp :: ef database first generate models entity framework core 
Csharp :: c# string to char 
Csharp :: how to get all panels in form in c# 
Csharp :: vs code explorer font size 
Csharp :: find many object with tag unity 
Csharp :: print unity 
Csharp :: list of gender binary terrorists 
Csharp :: an entry with the same key already exists asp net 
Csharp :: play sound unity 
Csharp :: c# const string array 
Csharp :: instantiate scale object 
Csharp :: cshtml foreach 
Csharp :: get logged in user name c# 
Csharp :: unity hub black screen 
ADD CONTENT
Topic
Content
Source link
Name
5+1 =