Frequently Asked Questions > Practical Questions > Working with Animation >

# How do I link the rotation of an object to the scene time?

MAXScript FAQ > Working With Animation > How do I link the rotation of an object to the scene time?

## A user asked:

I want to create a simple expression that will rotate an object based on the current time.

## Answer:

You can assign a Float Script Controller to the respective rotation sub-controller and use the current Time global variable to get the time.

FOR EXAMPLE,
if you want to rotate the object about its X axis, you should assign a Float Script controller to the .rotation.x_rotation.controller property:
    obj = Teapot()
    obj.rotation.x_rotation.controller = Float_Script()
    obj.rotation.x_rotation.controller.script = "currentTime"

This will rotate the object, but the rotation will be very fast because the time value is taken as radians, causing a full 360 degrees rotation every 6.28 frames!

To take the time as degrees,

YOU CAN USE
    obj.rotation.x_rotation.controller.script = "degToRad currentTime"

This will rotate the object 360 degrees in 360 frames. You can of course multiply the result by any factor to control the exact speed,

LIKE
    obj.rotation.x_rotation.controller.script = "0.1 * degToRad currentTime"

will rotate the object at 360 degrees in 3600 frames...

Another way to do the same is using the Float Expression controller. Unfortunately, it is not completely scriptable.

FOR EXAMPLE
    obj = Box()
    obj.rotation.x_rotation.controller = Float_Expression()

will assign a float expression controller to the X rotation track.

Now you can open the Expression window by going to the Motion tab, right-clicking the controller and selecting Properties...

ENTER THE EXPRESSION
    degToRad(F)

and press the Evaluate button.

The result should be the same as the Flot Script controller version.

#### See Also

- Frequently Asked Questions