Hi
I have a simple question. How do I go about rotation 4 degrees a Vector3 around the X axis?
I don’t want anything fancy, just rotate +4 around the X-axis. No idea how to do that on a script with unity :?
Hi
I have a simple question. How do I go about rotation 4 degrees a Vector3 around the X axis?
I don’t want anything fancy, just rotate +4 around the X-axis. No idea how to do that on a script with unity :?
From the example posted there;
// Slowly rotate the object arond its X axis at 1 degree/second.
transform.Rotate(Vector3.right * Time.deltaTime);
You can modify this to be;
// Slowly rotate the object arond its X axis at 4 degree/second.
transform.Rotate(Vector3.right * Time.deltaTime * 4.0);
Edit: Actually this assume the above code is placed in the Update call.
If you just want a single one time rotation, or a function that rotates it instantly 4 degrees per call;
function Bump4Degree()
{
// Rotate it 4 degrees
transform.Rotate(Vector3.right * 4.0);
}
If you’re specifically wanting to rotate a Vvector3 variable which isn’t attached to a Transform, use this:
newVector = Quaternion.AngleAxis(4.0, Vector3.right) * oldVector;
Charles, I’m not using the transform class. It’s a Vector3 type inside a script.