Community
Maya Animation and Rigging
Welcome to Autodesk’s Maya Forums. Share your knowledge, ask questions, and explore popular Maya animation topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

rotate object 360 loop

2 REPLIES 2
Reply
Message 1 of 3
maksymishyn
369 Views, 2 Replies

rotate object 360 loop

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 ?

2 REPLIES 2
Message 2 of 3
Kahylan
in reply to: maksymishyn

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
in reply to: Kahylan

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.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report