Hello,
I’m trying to rotate a model (over time) to point at a vector location. I am running into some problems with quaternions, floats and vectors.
I want to:
Figure out the angle between the current model’s direction and then rotate it over time until it points to the vector location.
I have tried:
var target = Vector3(random_x, 0.0, random_z);
var targetDir = target - transform.position;
var forward = transform.forward;
rotation_diff = Vector3.Angle(targetDir, forward);
While (rotation_diff>1.0){
transform.Rotate(0, Time.deltaTime, 0);
targetDir = target - transform.position;
forward = transform.forward;
rotation_diff = Vector3.Angle(targetDir, forward);
yield;
}
I’m getting an error 'cannot convert float to UnityEngine.Vector3 from this line “rotation_diff=Vector3.Angle(targetDir,forward);”
transform.LookAt works, but it does it instantly so the model just points in the new direction and doesn’t turn to it.
This must be a really simple thing to do, but I seem to be banging my head against the wall.Thank you for any help!
Jason