# Expression for wiggling snake

 04 April 2013 Sibben71 New Member portfolio Sweden 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 share quote
 04 April 2013 VB2341 Frequenter portfolio Varun Bajaj Troy, US 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=; 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. share quote
 04 April 2013 Sibben71 New Member portfolio Sweden 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 share quote
 04 April 2013 CGTalk Moderation Expert 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. share quote

 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 vBulletinCopyright ©2000 - 2006, Jelsoft Enterprises Ltd.