- Home /
Transform.Rotate not affected by Time.timeScale
I want to use a global slow motion effect in my scene, when I lower Time.timeScale the most stuff is slowed down except a few objects that uses really simple code :
function OnMouseEnter()
{
transform.Rotate(45, 0, 0);
}
Why is transform.Rotate not slowed down too?
Answer by Statement · Mar 29, 2012 at 01:33 PM
Because you aren't using Time.deltaTime.
function Update {
transform.Rotate(45 * Time.deltaTime, 0, 0);
}
Thanks for the fast answer but I made a mistake it should be in On$$anonymous$$ouseEnter function. And if I use Time.deltaTime, it is only rotating 1 degree.
@GameGuy: On$$anonymous$$ouseEnter only runs once, when the mouse enters. So Rotate will only get called once. Rotate doesn't "do stuff over time", it does its thing once, immediately. If you want Rotate to gradually rotate something over time, you have to call it repeatedly in small increments.
you can use On$$anonymous$$ouseOver if you want this to happen every frame your mouse is on the object ;) http://unity3d.com/support/documentation/ScriptReference/$$anonymous$$onoBehaviour.On$$anonymous$$ouseOver.html
After searching around in the Script Reference again, I guess I can forgot about my dream to use a unity built in command for that and need to create a custom function. @The Oddler nice idea but I need a global slowmo effect in combo with On$$anonymous$$ouseEnter. @Eric5h5 Thanks for clearing this out.
Use a coroutine...start it in On$$anonymous$$ouseEnter and stop it in On$$anonymous$$ouseExit.
Your answer
![](https://koobas.hobune.stream/wayback/20220613065702im_/https://answers.unity.com/themes/thub/images/avi.jpg)