My spinning objects got slow

Just a super quick question. So I decided to build and run my little obstacle course. For some reason the spinning objects got kind of slow vs how it spins in unity. Does this have anything to do with because I didn’t add Time.deltaTime to the rotation code? I remember one of the lessons saying that forces the speed to stay the same since void update goes by per frame which could be slower or faster depending on the computer. Am I correct on this or am I off lol?

Hi Zhaine,

How do you rotate the object? Could you share the relevant piece of code here? If your game object slows down without Time.deltaTime, I would rather suspect a really low framerate. You would notice that, though, because the game would be fairly laggy.

The only thing that slows down is just the objects I have spinning. Everything else looks good.

void Update()
    {
        transform.Rotate(xRotate, yRotate, zRotate * Time.deltaTime);
    }

I tried to add the Time.deltaTime in it the same way it was added onto the player movement script but it doesn’t appear to do anything.

Edit: When I press play in Unity it looks fine and spins at where I like it to be but if build the game and launch it the spinning objects slow down.

There is a strange bug in Unity which prevents the game objects from rotating properly when they are selected in the Hierarchy. Try to select something else and click into the game window once to set Unity’s focus on the game window again. Then run your game.

The game window is just a preview. The behaviour is often slightly different.

If your moving or rotating game object has got a collider, add a Rigidbody to it as well.

Multiply all rotation values by Time.deltaTime, not just the z-value.

Last but not least, you could test this (minus the turn part):

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms