Announcements

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

rotate object 360 loop

rotate object 360 loop

maksymishyn
Explorer Explorer
1,001 Views
2 Replies
Message 1 of 3

rotate object 360 loop

maksymishyn
Explorer
Explorer

Hello. 

I have a wheel, when it rotates the lights should flash.

when the wheel makes a turn of 30 degrees, the light (A) lights up ; 120 degrees , the light (B) light up...

but after 360 degrees my wheel keeps increasing degrees 361 , 362++

how to make a loop (in expression)so that after 360 the wheel starts from 0 ?

0 Likes
1,002 Views
2 Replies
Replies (2)
Message 2 of 3

Kahylan
Advisor
Advisor

Hi!

 

Writing an expression like this would be easy, I would advice against this solution. Eventhough it will look correct in the viewport, if you render with motion blur, the motionblur on the wheels will be very inconsistent. Since the wheels will turn 359 degrees backwards on a single frame

I would rather look, that you lights just react to all the correct values. For example, your light A lights up at 120 but also at 480, 740 and so on.

 

The easiest way to achieve this, is to use a cycled set driven key. You use your wheels rotation value as the driver, then you animate the range of 0 to 360 degrees with the light turning on and off at the correct points. After that you just need to set the pre and post infinity curves to cycle and your lights should work correctly at every rotation of the wheel.

 

I made a short video to show how this is done, because I find that set Driven Key setups are always a bit confusing when the are just described in text:

 

https://youtu.be/ckb6_ZesKLA

 

I hope it helps!

 

 

Message 3 of 3

maksymishyn
Explorer
Explorer
Thanks a lot for your help Kahylan !
The method works but I started to study scripts and I have an internal solution for the code.

pCube1.rotateX = frame/24 * 30 % 360 ;
if ( 30 < $pCube1.rotateX )
{pCube2.translateX = 5 ;}
else
{pCube2.translateX = 0;}
this is practically what you did only with code :
but i dont know how to make range in mel if ( 30 < $pCube1.rotateX <60) how it works in python ??
thanks again.