how do i make a vector into a quaternion

else{transform.rotation = Quaternion.RotateTowards(transform.rotation, randomvec, turnrate);}

i have a var randomvec set to a randomly generated vector every 5 seconds, i want to make the vector into a Quaternion so the transform can rotate towards it, i can’t think of any way to do this, and would like a method or an alternative to this, thanks for the help in advanced.

Because of gimbal-lock problems, there is no way to perfectly convert a Vector3 into a Quaternion. Because Quaternions actually contain more information about an object’s rotation than a Vector3 ever can, you will always lose data.

Of course, if you make some assumptions about how your object should act, it’s easy enough to fake it.

If you use Quaternion.LookRotation, it will return a quaternion that accurately looks towards the specified vector, always keeping the head pointing towards the ‘up’ vector. In most cases this is exactly what you want.

Quaternion.LookRotation(randomvec, Vector3.up);

Of course, if you just want a random Quaternion, you can always just use Random.rotation…