Horje
unity making homing missile Code Example
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;




Csharp

Related
linq select max value from list Code Example linq select max value from list Code Example
c# find element in list of list Code Example c# find element in list of list Code Example
c# handle single quote inside string Code Example c# handle single quote inside string Code Example
adding to a dictionary unity Code Example adding to a dictionary unity Code Example
c# read xml tag value Code Example c# read xml tag value Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
9