Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

unity how to rotate something to point to something else

Vector3 dir = target.position - transform.position;
Quaternion lookRotation = Quaternion.LookRotation(dir);
Vector3 rotation = Quaternion.Lerp(partToRotate.rotation, lookRotation, Time.deltaTime * turnSpeed).eulerAngles;
partToRotate.rotation = Quaternion.Euler(0f, rotation.y, 0f);
Comment

PREVIOUS NEXT
Code Example
Csharp :: check internet connection in c# 
Csharp :: c# winforms textbox readonly 
Csharp :: how to draw a rectangle in monogame 
Csharp :: c# thread wait 
Csharp :: new parameterized thread c# 
Csharp :: game object set exact position unity 
Csharp :: csharp datetime string format 
Csharp :: iactionresult 
Csharp :: c# convert enum to list 
Csharp :: iterate through xpdictionary devexpress 
Csharp :: change picturebox image c# 
Csharp :: c# string newline 
Csharp :: unity get selected gameobject 
Csharp :: how to configure session timeout in asp.net core 
Csharp :: how to split list by date c# 
Csharp :: if cluse in class in vue 
Csharp :: unity change material 
Csharp :: unity remove parent 
Csharp :: net use delete 
Csharp :: rotate object to mouse position unity 
Csharp :: changing euler angles unity 
Csharp :: remove first character in a string c# 
Csharp :: c# split text by spaces 
Csharp :: c# inline a function 
Csharp :: c# remove from list in foreach 
Csharp :: unity new Color() 
Csharp :: c# compile into an exe 
Csharp :: unity target frame rate 
Csharp :: get 2d rotation from 2 position math 
Csharp :: c# skip following code in loop 
ADD CONTENT
Topic
Content
Source link
Name
9+7 =