1. ## Expression help!

Ok, here's what i am trying to do (sorry if this is a long explanation) if you don't want the explanation and just want to help me write the expression, just read the last paragraph.

I am using a small patch of grass as a shadow catcher for a tire to drive over. the grass object will be parented to the tire so it always stays under it, how ever i want the grass to appear to stay in one place until the tire gets close the edge of the grass at which point a new piece of grass spawns in under the tire. believe it or not, I am very close to making this work. I gave the grass two morph maps, one moves the grass in the x direction half the length of the grass object. the other morph map moves it in the z direction half its length (the grass is 2 square meters). this means i can move the tire object 1 meter in the x, and have the X morph map on the grass counter that movement by moving the grass 1 meter in the negative. i do this by setting the value of the morph map equal to the the negative number of the tire position. the end result is the grass stays in one place as the tire moves around despite it being parented to the tire (half way there!!).

so this is what i need from the expression. I want a morph maps value to be reset to %0 every time it reaches %100. the value of the morph map is being driven by the position of another object. I hope that makes sense. i should also point out that i really suck at making expressions.

2. It sounds like a mod() (Modulus) operator:

mod( <your existing expression>, <value causing 100% morph> )

Note that the second parameter is the value of your existing expression which results in the 100% morph. So, for example if the wheel rotation is 360 degrees (2-pi radians) when the morph tops out, it might look like this:

mod ( [Wheel.Rotation.P] , 2*3.14159 )

mTp

3. Originally Posted by MonroePoteet
It sounds like a mod() (Modulus) operator:

mod( <your existing expression>, <value causing 100% morph> )

Note that the second parameter is the value of your existing expression which results in the 100% morph. So, for example if the wheel rotation is 360 degrees (2-pi radians) when the morph tops out, it might look like this:

mod ( [Wheel.Rotation.P] , 2*3.14159 )

mTp

Thanks mTp, I'm not sure I understand. i don't quite understand how Mods work. right now i have the morph controlled just by the position of a null. so the null moves 1 meter, which causes the morph to add %100. so my expression just looks like "[Null.Position.X]". when the null moves another meter, that means the morph is set to %200. i need it to reset back to %0 and add the next meter. does that make sense?

4. Modulo (mod, %) operations return the remainder of a division operation; ie, 3 mod 2 returns 1, while 4 mod 2 returns 0. X % 1.0 will always give you a value of 0 <= result < 1.

It is functionally equivalent to A - (A * floor(A / B)).

Please note that things get strange when B < 1.0.

https://en.m.wikipedia.org/wiki/Modulo_operation

5. Originally Posted by Kryslin
It is functionally equivalent to A - (A * floor(A / B)).
LOL, I'm sure this bit is correct, but it's always amusing (a moi) when the explanation is more confusing than the thing it's explaining.

The first sentence is very clear, and I think madmike will get it from that.

6. Worked like a charm! thank you so much.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•