Jump to content

Piston like rigging


Recommended Posts

Hi guys!

I need to do a sort of piston assembly, that consists of 2 cilinders/pistons... while one goes up theother goes down and vice-versa.

Of course that negating the value of one piston (in ty), thus making the other -ty doesn't do the trick! The other one will go down and it will even start to go up, but only to the minimum value of the other.

I need something that allows me to say: If the other one is going up, you will go down but if the other one starts to descend, you'll start to rise...

Ok, ok... I need (probably) an if statement... But I didn't managed to make it work properly...I tried to fit the value the other piston would have to assume but without sucess...

Can someone explain me how to do it or if there's a different way (in Max you would use some look at constraints or something similar and so on... but here the look at is at Scene level :( )

I'll attache my file...

piston.hipnc

Thanks in advance for your time!

Edited by J.Santos
Link to comment
Share on other sites

Guest Swann


if(ch("../xform5/ty") > 0, -ch("../xform5/ty"), if(ch("../xform5/ty") < 0, abs(ch("../xform5/ty")), ch("../xform5/ty")))

Link to comment
Share on other sites

Hi Swann!

Thanks man! I was thinking "How can I add an else here?... Of course, an if inside another... duh to me!!!

In the meantime I thought of another soluction, that doesn't involve expressions and probably will work better for what I want... but anyway, this will be great for future references!!!

Thanks again man!!! :)

Link to comment
Share on other sites

Hi again!

I ended up using this expression to solve my piston problem:

if(ch("../master/constraintBack") >= 0.35, 0.8 - ch("../master/constraintBack"), (0.25 / ch("../master/constraintBack") - 0.3))

someone might be interested...

Swann's code works like a charm but (as far as I could test and try it out) only if the values range from positive to negative (and so the use of abs( ) to change the value). Since in my piston the values go from 0.1 to 0.8 I had to use a different approach...

I hate having to use "magic numbers" but they are all logical (IMO :) ) 0.8 as the maximum value/height in ty, 0.35 as the average(half...) of 0.7 and the 0.3... no ideia! :) But it worked... there's a small "jump, but it's so small that probably will not be noticed and can be hidden...

This might not be the best solution but it worked for me so I'm quite happy!

Once again my thanks to Swann that teached me a bit more...

Edited by J.Santos
Link to comment
Share on other sites

i am not sure what you are doing and how your expression behaves in your scene, but when i tried it it prodices values from 2.2 to 0

if you just want to reverse the piston movement you can just use

fit(ch("./constraintBack"), 0.1,0.8,0.8,0.1)

but maybe i've missed your intention

Edited by anim
Link to comment
Share on other sites

Guest Swann

or just paste this


  0.9-ch("constraintBack")

into your master control frontPiston field instead of your expression.

Edited by SWANN
Link to comment
Share on other sites

Hi Anim!

Yeap... those are the values :) Confused? So was I... but I forgot to mention that I did constrained the values (or rather the range) to never go below 0.1 or above 0.8... so the rest of the values could be produced (and indeed are) but in my animation that's seamless... I know that's not the most efficient way and I'm "throwing" away those poor old values that are out f my range but... it worked! But now I can remake the expression to be more efficient! And with that I learned something...

Thanks for your expression I'll try it out tomorrow!

Hi Swann!

Thanks for your follow up... and yeap, I think you hit the nail with that expression! Really simple and should work well...I'll try it tomorrow and post the results! Thanks! This only proves that the simple ways are always better...

Thanks again to both of you guys! Have a great weekend!!!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...