So that’s the problem now.
I have an object, and i want ot rotate it from 0 degrees to 90 degrees (it’s a door) when i click a mouse button.
My problem is that i cannot get the object rotating smoothly within time, i mean, i tried with Time.deltatime, also tried with Quaternion.Slerp, but no solution, i’m on this by 2 hours now.
Help please.
Thanks.
no one with anything?
pleaaaaaaaaaaaaase.
It’s not rotate the object ALL the time, only when i change a variable from 0 to 1 and the angle must be from 0 to 90 degrees.
Thanks.
If I understand your problem correctly, there’s probably many ways to accomplish this… but here’s what I did with a pinball flipper, and it should be the same concept.
First I had this code in GlobalVar.js:
static var flipperRot = 90;
static var rotSteps = 10;
Then, this code was in a different .js file:
private var leftShiftDown = 0;
function Update () {
if (Input.GetAxis("LeftFlipper") == 1) {
if (leftShiftDown < GlobalVar.rotSteps) {
transform.Rotate(Vector3(0,0,-1)*(GlobalVar.flipperRot/GlobalVar.rotSteps));
leftShiftDown++;
}
}
if (Input.GetAxis("LeftFlipper") == 0) {
if (leftShiftDown > 0) {
transform.Rotate(Vector3(0,0,1)*(GlobalVar.flipperRot/GlobalVar.rotSteps));
leftShiftDown--;
}
}
}
The second .js file looked at the first one for its variables, and then, whenever the left Shift button was pressed, the flipper would rotate up to a certain point and then stop. When the left Shift button was released, the GetAxis variable had changed, so the flipper would go back to its original state.
Sorry… I didn’t comment the code at the time. But hopefully this makes sense.
I think you helped me a lot
i must study this a bit, but i think this can solve my problem.
Thanks! 