I’m trying to move an object a set distance based on another object’s rotation.
Sounds simple. So I add driver to the object I want to move.
Scripted expression.
Object is the rotation object, X Rotation, Auto Euler, world space (doesn’t seem to do anything if it’s set to local).
Expression:
(degrees(var/-35))±0.46546
The driver value goes from -.465 to 1.53. It’s rounding, but those are the two inches of movement I need when the object rotates -70 degrees.
But the actual output going to location is Way different, and I don’t understand why. That’s going from -18.325 to 60.415
I mean, I solved that math easy enough. I just had to make it look like this: ((degrees(var/-35))±0.46546)/35
But why the heck does That make sense? Why can’t I just output the driver value to the location?
So yeah, I got something to work. But I don’t understand it, which is never good.
Would you like to upload a Blend file for the forum to take a closer look at? Some of us are more effective with muscle and visual memory, and this might help your chances of getting an answer for this.
I totally would share it, but it’s basically our actual CAD data, so I created a new file. There are 3 objects. The door, the object named bulb, and a base. If you don’t want to imagine it with boring primitive shapes then here’s a reference: AVAUV The website isn’t live yet, but I guess we have it showing on our portfolio page already, so that much is public. Obviously a render, don’t judge me on the photo integration ones. It’s really hard to match perspective of images that have been cropped and maybe image shifted. And the auto one, like 20% of the image on the right is just me painting because they wanted more image (keyshot for now, but blender animation hopefully coming soon).
So I tried to do everything the same as I did before to replicate the question I had. I saved it with the first expression, the one I expected to work. I didn’t really need an offset of .04 here, but did it anyway because in my actual file I needed an offset of -.465 DoorDriver.blend (735.4 KB)
So the part I’m confused about is in the driver value it shows .04 to -1.96, so there are the 2 inches I expected. I’m rotating 70 degrees, so divide by 35 gives me the 2 inches of movement. Oh how I wish for “set driven key” from Maya. It is SO much simpler for artists to use (you don’t have to know math).
But you’ll notice, when you scrub the timeline, that it actually translates from 1.57 to -77.16, which is 78.74? (rounded). Divide that whole expression by 35 and then the location is .04 to -2.2
I see now that my expression also should have been something more like: ((degrees(var/-35))/35+.04)
But the thing I’m confused about is the driver value. Isn’t that the value the expression is outputting?
Also I did the animation as an action. I’m doing my best to try and figure out how to work as a team, so someone can set up the animations of the actions, then the other person can use those for animating the “story”. Opening the door never changes. And the bulb is linked to the door opening. It’s kind of cool. Opening the door gets the bulb out of the way a bit, then when you close it, it pulls it right back on top of whatever you put in there (most likely a cell phone).
Did you nudge the curve in your screengrab? I just opened the file I posted and it doesn’t look like that for me.
I’m brand new to this, and this is as far as I could figure out based on reading and watching other people use it. Sometimes that gets you right where you need, and sometimes you’re still left quite a bit in the dark.
So as a test, I just changed the expression to var. I don’t know of another way to connect X rotation to Y position.
Then I went over to the F-Curve tab and change one key to frame 0 and 1"
Then I selected the other and changed frame to -1.22 (70 degrees in radians?) and change the key value to 2"
It does appear to move 1 inch. So other than having to calculate radians that does Seem easier? This is closer to maya’s set driven key. But there, you set both values at one extreme, set a driven key. Then you set the other extreme values, and set another driven key, and that gives you your F-curve essentially. Then you can tweak the speed of the curve if you want. In my case I just want linear since the animation of the other object will have the easing.
But wait, it helped me look at just using the curves.
I didn’t see Anyone on youtube use the curve for anything. I’ll try to look for that more specifically next time.
What I was confused at was the number in the “Driver Value”. That’s the number I expected to be pushed out to the Y location. But I had to divide by 35 a second time. If you look at the actual translated value, the file I posted goes from 1.57 to -77.16. That’s the part I am confused about.
I believe it has to do with the custom units you’re using. I believe your driver is outputting meters. (Really, it’s outputting “pure” blender units. Meanwhile, your transform display is displaying in inches.) It’s just a coincidence that’s there’s close to 35" in a meter.