- Home /
shaft rotation
I have to rotate a shaft of the machine, but when I'm doing this, the shaft rotates from 0 ° to 90 °, then jumps to 85 and goes to 90, and so on. this is my java script:
var target: Transform;
function Update ()
{
rotacion=(hz_var*0.5);
if(hz_var!=0) target.localEulerAngles += Vector3(rotacion,0,0);
}
//hz_var is velocity of rotation and I tried with (Eulerangles.x)
Answer by Tim-Michels · Jul 06, 2012 at 10:08 AM
Why not use target.Rotate(Vector3.left, rotacion);
You can adjust the axis you're rotating on, but the idea remains the same.
yes, but problem is that Rotation angles only are range between -90 y 90°
Well, then it's probably your calculation of your rotation itsself. (hz_var)
I don't exactly know what you're trying to achieve, but to have an object rotating at a constant speed, you should just increment the rotation value continuously.
Example: (each frame)
hz_var += Time.deltaTime * rotationSpeed;
That way, your eulerangle will increase constantly each frame, independent of your framerate.
Cheers
OH,the acceleration is perfect but my object always rotates wrong.
If you mean your object rotates around the wrong axis, you have to change the Vector3.left to whatever axis you want it to rotate. There's also Vector3.forward, Vector3.up, ...
You should experiment with different axis.
Your answer
Follow this Question
Related Questions
Is there no way to get reliable angles from a rigidbody? 2 Answers
Making an objects y Rotation match another objects Z 2 Answers
ConfigurableJoint - angular positions (rotation) problem 1 Answer
Can I convert an eulerangle with negative values to the corresponding positive values? 0 Answers
Why Local Rotation Faster than World Rotation (Degrees/Second) 1 Answer