# SimplyMaya Forums

Welcome to the forum, feel free to ask questions here.

Home / forum / Animation / Mel Scripts & Programming / expression for oscilating movement
 Register FAQ Members List Calendar Mark Forums Read

 04-02-2004, 12:43 AM #1 danrocha Subscriber     Join Date: May 2003 Location: Campinas - SP - Brazil Posts: 30 Thanks: 0 Thanked 0 Times in 0 Posts expression for oscilating movement Hello I need an expression to make a ball go up and when it reaches a certain height, it kinda oscillates, as with those popping toy clowns coming out of boxes attached to a spring... I have tried several approaches but can't get this to work! I'll try to explain it more clearly: I have a ball. I want it to go UP (y axis only) in a accelerated movement, which begins really fast (like an explosion) and slows down abruptely at the end (as if it was attached to a spring); then it goes down a little, then up again, down again, etc, with its speed going down until it stops (or keeps oscillating real slowly).... Maybe it is too complicated, and I should try another way to do this? Please heeeeelp thanx a lot Daniel __________________ "The hardest thing to see is what is in front of your eyes" Goethe
 04-02-2004, 02:15 AM #2 kbrown Moderator     Join Date: Sep 2002 Location: London, UK Posts: 3,198 Thanks: 0 Thanked 8 Times in 8 Posts Keyframing gives you the best control. You could do it with an expression too but is it really worth it? Here's one possibility: Code: int \$iStartOsc = 6; float \$fHeightMult = 3; int \$iStopFrame = 75; if(frame < \$iStartOsc) nurbsSphere1.translateY = frame * \$fHeightMult; else if(frame < \$iStopFrame) nurbsSphere1.translateY += \$fHeightMult * sin(frame - \$iStartOsc) * ((\$iStopFrame - frame) / \$iStopFrame); __________________ Kari - My Website - My IMDB Do a lot, Fail a lot and Learn a lot!
 04-02-2004, 02:21 AM #3 mtmckinley The Maya Mountain     Join Date: Aug 2002 Location: Seattle, WA Posts: 8,245 Thanks: 1 Thanked 25 Times in 25 Posts you might could use a dynamic constraint with some gravity and initial movement and such. Check out the Dynamic Constraints tutorial we've got here for more info. __________________ -Mike www.mtmckinley.net The Maya Toolbelt
 04-02-2004, 10:07 AM #4 danrocha Subscriber     Join Date: May 2003 Location: Campinas - SP - Brazil Posts: 30 Thanks: 0 Thanked 0 Times in 0 Posts Thanx a lot... I've tried then to use a spring constraint, played around with its damping and stiffness attributes, and got pretty much the movement I needed. As I need lots of balls doing exactly the same movement, I'll try to duplicate them and to use diferent keys to control the activation of the constraint. I'll try to implement the code, anyway. See what works best Daniel __________________ "The hardest thing to see is what is in front of your eyes" Goethe

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts vB code is On Smilies are On [IMG] code is On HTML code is Off

## \$34

Month-to-month billing

## \$87

Billing every 3 months
 \$29/month Unlimited access to all videos Project files to download Easy to cancel at anytime Save \$5 per month or \$15 in total compared to monthly billing with this package.

## \$288

Billing every 12 months
 \$24/month Unlimited access to all videos Project files to download Easy to cancel at anytime Save \$10 per month or \$120 in total compared to monthly billing with this package.

Your plan will automatically renew. You can cancel at any time via your PayPal account to avoid being charged again.

You can view the FAQ on our video plans here. You can contact us directly here. By clicking one of the buttons above, you agree to our Terms and Privacy Policy.