# Rotating objects in time.

**URL:** https://discussions.unity.com/t/rotating-objects-in-time/394330
**Category:** News & General Discussion
**Created:** [July 2, 2009, 6:24pm UTC](https://discussions.unity.com/t/rotating-objects-in-time/394330 "2009-07-02T18:24:34Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![anon\_53105002](https://avatars.discourse-cdn.com/v4/letter/a/e495f1/32.png) [@anon\_53105002](https://discussions.unity.com/u/anon_53105002)
#### Post date: [July 2, 2009, 6:24pm UTC](https://discussions.unity.com/t/rotating-objects-in-time/394330/1 "2009-07-02T18:24:34Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![anon\_53105002](https://avatars.discourse-cdn.com/v4/letter/a/e495f1/32.png) [@anon\_53105002](https://discussions.unity.com/u/anon_53105002)
#### Post date: [July 2, 2009, 8:06pm UTC](https://discussions.unity.com/t/rotating-objects-in-time/394330/2 "2009-07-02T20:06:33Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Screenhog](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/screenhog/32/410730_2.png) [@Screenhog](https://discussions.unity.com/u/Screenhog)
#### Post date: [July 2, 2009, 8:38pm UTC](https://discussions.unity.com/t/rotating-objects-in-time/394330/3 "2009-07-02T20:38:14Z")

</div>

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:

```auto
static var flipperRot = 90;
static var rotSteps = 10;

```

Then, this code was in a different .js file:

```auto
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.

---

<div class="post-metadata">

### Author: ![anon\_53105002](https://avatars.discourse-cdn.com/v4/letter/a/e495f1/32.png) [@anon\_53105002](https://discussions.unity.com/u/anon_53105002)
#### Post date: [July 2, 2009, 11:42pm UTC](https://discussions.unity.com/t/rotating-objects-in-time/394330/4 "2009-07-02T23:42:32Z")

</div>

I think you helped me a lot 🙂 i must study this a bit, but i think this can solve my problem.

Thanks! 😄
