Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

unity making homing missile

//using the cross-product is quite effective 
//Note: This is quite usefull for rigidbodys... 
//but you can also use that for transform with some code adjustments
Vector3 targetDir;
Vector3 currentDir = transform.forward; //whatever your currentDir is

//the cross product returns the axis you want to rotate around
Vector3 crossProduct = Vector3.cross(targetDir, currentDir);
float magnitude = crossProduct.magnitude;
rigidbody.angularVelocity = crossProduct.normalized * speed * magnitude;
Comment

PREVIOUS NEXT
Code Example
Csharp :: get the number of cpu c# 
Csharp :: c# func 
Csharp :: entity framework core genetare class using existing database 
Csharp :: c# get all classes derived from type 
Csharp :: primitive types c# 
Csharp :: c# replace multiple characters 
Csharp :: pyqt minimize to tray icon 
Csharp :: how to show process time run c# 
Csharp :: defualtsize UWP c# 
Csharp :: how to insert value to identity column using entity framwork 
Csharp :: in c sharp how do you work the wait function 
Csharp :: c# chunk array linq 
Csharp :: ActionExecutingContext result response return 
Csharp :: unity position ui element 
Csharp :: reload usercontol wpf 
Csharp :: declare string array c# without size 
Csharp :: change line color in c# 
Csharp :: get min date in list c# 
Csharp :: c# tuple 
Csharp :: how to use double in c# 
Csharp :: center mouse unity 
Csharp :: httpclient 
Csharp :: .net core change localhost port 
Csharp :: unity werfen mit höhe 
Csharp :: c# instance class with ilogger 
Csharp :: c# merge two lists as queryable 
Csharp :: how set format persian data picker to en 
Csharp :: unity c# destroy gameobject 
Csharp :: pick random point inside box collider unity 
Csharp :: dictionary all key where value c# 
ADD CONTENT
Topic
Content
Source link
Name
5+8 =