Expression for wiggling snake

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
  04 April 2013
Expression for wiggling snake

Hello

I've made a snake, or more like a snail, creature. It bends its body vertically when it moves similar to how a snake wiggles but just on another axis. I've set it up as SDK with an attribute (a float but it could be an integer I guess) that performs "one bend" so to speak. I can move the animal forward and then key the attribute to perform the bend and relax part.

My question is how to make an expression to do this automatically, similar to how you would make a wheel roll when translating. I'm new to creating attributes and can't really figure out how it would work.

I understand that somehow I would have to decide that for "each X units of translation" the bend should happen and then relax.

I would really appreciate any help I can get.
Cheers,
Sibben

 
  04 April 2013
Well, since you're using SDK, you have to have the values of the driver repeating I think. If the two ends of the SDK have the snake in the same position, then it's fairly easy. If this is the case, the driver has to get up to the maximum value, and then go back down to the minimum value. The modulo operation is great for this. I don't have Maya in front of me, but I think if you wanted to use translateZ to make the driver work, it would look something like this:

float $length=<insert length value here>;
snake.driver=snake.translateZ%$length;

You'll have to replace names appropriately. The length value I created is the units covered per bend that you mentioned. It might be a good idea to create this as an attribute of your control object or something, so you can tune it's value until you find what looks nice. The % in the example expression is the modulo operator. If you're confused about this operator, there's plenty of resources out there to explain it (it's a simple mathematical operator that gives the remainder after division). Let me know if I can help any more.
 
  04 April 2013
Thanks VB!

No the SDK is not a full motion and return but that´s an easy fix. I'll start by making sure it is and try your expression. Again thanks for the help.

Sibben
 
  04 April 2013
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



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
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright ©2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 04:30 PM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.