back in time

Hi guys, I am trying to write a script for creating random rotations based on current time (and previous frames). I want some objects to follow another objects rotation but with the flexibility of having the rotation performed at arbitrary frames. If that is not clear, the laymans term would be:

"rotate an object to the rotation of another scene objects rotation 10 frames ago"

I am using the sin function and float scripts for each object axis. Below is the code for the base object rotations followed by what I thought would be the right syntax.I have done a similar thing in MEL, so the basic principal is the same, I just need to know where I have gone wrong in Maxscript.

--base object rotation control

$.rotation.x_rotation.controller = Float_Script()
$.rotation.x_rotation.controller.script = "sin(5 * (degToRad currentTime * 100)"

$.rotation.y_rotation.controller = Float_Script()
$.rotation.y_rotation.controller.script = "sin(5 * (degToRad currentTime * 100)"

$.rotation.z_rotation.controller = Float_Script()
$.rotation.z_rotation.controller.script = "sin(5 * (degToRad currentTime * 100)"

--second objects rotation control

$.rotation.x_rotation.controller = Float_Script()
$.rotation.x_rotation.controller.script = "sin(5 *(degToRad (currentTime -10f) *100))"

$.rotation.y_rotation.controller = Float_Script()
$.rotation.y_rotation.controller.script = "sin(5 *(degToRad (currentTime -10f) *100))"

$.rotation.z_rotation.controller = Float_Script()
$.rotation.z_rotation.controller.script = "sin(5 *(degToRad (currentTime -10f) *100))"

--End of script

Thanks very much.

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Anubis's picture

syntax...

Well, just test your expressions in the Listener window, without quotation marks of'cuz.

In the first expressionL sin(5 * (degToRad currentTime * 100) the closed bracket is missing, it s'd be sin(5 * (degToRad currentTime * 100)).

In the second, your code: sin(5 *(degToRad (currentTime -10f) *100))
Corrected: sin(5 * (degToRad (currentTime - 10f) * 100))

As you see, the intervals are important. Try in the Listener this one:

currentTime - 10f -- that work
currentTime-10f -- that work too
currentTime -10f -- that Not work
currentTime + -10f -- that work

The 3d line is readed like 2 values without operations.
I hope this help

my recent MAXScripts RSS (archive here)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.