I can't understand why it doesn't work. Driver value should be 0 according to my expression. Can't figure out what is wrong with it.

enter image description here


I wouldn't trust the value in a quaternion to exactly equal a whole number.

There are decimal numbers that a base two floating point number can't represent, for the same reason that you can't represent 1/3 exactly in base ten. While -1 isn't one of those numbers, it's conceivable and probably to be expected that some minute inaccuracy would have been introduced in producing the number that's used for that driver channel.

Try this:

0 if abs(-1-var) < 0.001 else 1


0 if var < -0.999 else

  • 1
    $\begingroup$ Thanks! That's interesting, didn't know those "value" numbers might be rounded! $\endgroup$
    – Anna
    Mar 19 '21 at 2:12
  • 8
    $\begingroup$ math.isclose is also available 0 if isclose(var, -1) else 1 $\endgroup$
    – batFINGER
    Mar 19 '21 at 2:42
  • 4
    $\begingroup$ or since booleans convert to ints in drivers in this case could use 1 - isclose(var, -1) or not isclose(var, -1) $\endgroup$
    – batFINGER
    Mar 19 '21 at 3:51
  • $\begingroup$ It says "slow python expression" and refuses to execute it, so I guess no luck here $\endgroup$
    – Anna
    Mar 19 '21 at 13:48
  • 1
    $\begingroup$ @Anna Try to enable Auto Run Python Scripts in the Save & Load preferences $\endgroup$
    – Gorgious
    Mar 19 '21 at 15:28

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.