Hah, thanks Neil! It’s good that someone knows the Unity API ![]()
d.
Hah, thanks Neil! It’s good that someone knows the Unity API ![]()
d.
I still keep forgetting that Vector.Angle() exists and end up using acos(dot(…)) instead. ![]()
For a more elegant solution to this problem, I thought I would post what people suggested in code form.
var newAngle = Vector3.Angle(currentVector, desiredVector);
var whichrotate = Vector3.Cross(currentVector,desiredVector);
if (whichrotate.z < 0){
newAngle = newAngle * -1;
}
cheers!
for the future, the dot product of two vectors can very effective determine the “sign” you want of an angle as well.
var angleFromForward = Vector3.Angle(transform.forward , directionToMove); //from straight, whats the angle we are going towards
var leftRightVector = Vector3.Dot(transform.right , directionToMove);
//if its + == right of the previous angle
//if its - == left