1
$\begingroup$

Let's say I have an "empty" that I want to only be able to move in the X axis, and only between 0 and 1. I can turn on the transform locks for Y and Z, but how do I limit X to only values between 0 and 1?

I tried the "Limit Location" constraint but it doesn't actually limit the actual value of the property, so unfortunately any drivers or expressions referencing that property will still see values out of that range even if the physical object appears to be within range.

$\endgroup$
2
$\begingroup$

You can use a driver to do that:

enter image description here

Right click on the X location in the object's property panel and choose "manually create later (single)".

enter image description here

Now open a view with the graph editor (1)

Set it to drivers mode (2)

Select the X Location on your object (3)

Make the right panel appear (4) N, choose the driver tab, set the type to "scripted expression", check "use self" so that we can use object's own data. For instance here X location is "self.location[0]".

Then enter the wanted expression. To be between 0 and 1, type: min(1,max(self.location[0],0)).

enter image description here

$\endgroup$
0
$\begingroup$

A simpler way to do this, if I understand the question, is to select the object, open the constraints tab, add object constraint, limit location. In this panel you can set min and max values for transform channels. So if you are using an empty object transform as a driver for the alpha value on a material, you could constrain the min max values to 0 and 1 on that channel.enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.