unity making homing rocket
//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;
Also in C#:
- c# join string array
- c# initialize array
- C# how to get public key for InternalsVisibleTo
- c# stop loop in method
- C# webclient immitate browser
- cannot convert string to generic type c#
- unity face direction of movement
- Unity C# add slider into editor
- reference to gameobject in different scene unity
- c# how to run external program
- iterate through xpdictionary devexpress
- vb.net check if datatable has rows
- get random number c#
- isGrounded script for copy
- see if two string arrays are equal c#
- if else statement
- internal c#
- c# initialize empty array
- What is a class in c#
- how to make a datatable in c#
- c# find index element array
- c# string code ascii
- c# string array
- Could not load file or assembly 'Ubiety.Dns.Core, Version=2.2.1.0