how to find a new vector direction from exsisting one

Hi ,

transform.translate(vector3.up * speed * time.deltatime);
but I want to move my gameObject with varied angle from vector3.up.

transform.translate(newDirectionvector * speed * time.deltatime);
my approach :
what I assume is from the vector math
NewVector = OldVector * Cos(thetha); // from dot product formula
input will be any value theta 0 to 360.
will this approach gives me a new direction vector.

Quaternions should be used here. Now I’m not sure which axis you want to rotate around since you’re in 3D, but I’ll assume theta is one of the euler angles you want to rotate by.Vector3 rotatedVector = Quaternion.Euler(0f, 0f, theta) * originalVector;Once you have a Quaternion representing a rotation, you multiply Quaternion * Vector to rotate the Vector by that Quaternion. You cannot put the Quaternion on the right, Eg: Vector * Quaternion (ERROR) as the matrix math is undefined!

1 Like

Thanks Gath Smith,

It Worked as I expected.
Thanks for u r quick reply too.