If Statement In A Driver | Blender Drivers Master Class
Vložit
- čas přidán 29. 01. 2021
- Hello everyone, I hope you are all well.
Here is a quick video reviewing if statements in Blender drivers.
0:37 - Skip that intro!
Let me know if you have any questions in the comment below!
.........................................................................
●Website: levelpixelleve...
●Patreon: / levelpixellevel
●Twitter: / levelpixellevel
●Instagram: / levelpixellevel
●Pinterest: www.pinterest....
.....................................................................
Really helpful. As an ex-coder, I found it miles easier to do this than faff around with chains of math nodes! Thank you so much!
Wow I never knew you could have python logic in drivers. SO MANY NEW POSSIBILITIES
thanks, this is EXACTLY what i was looking for! thanks for sharing :)
Very useful tip, much easier than having to do some separate script. Thanks!
you are a legend thank you so much, been searching for a solution for this exact problem for about 2 hours now
Well I am not a programmer but this blows My mind...
Great video! Love this driver series, keep up the great work
Great video thank you, I’ve been looking for this a while ago, and I don’t even remember what I was going to use it for.
This is very useful method, thank you for great explanation!
Excellent.
Just what I needed!
Thanks a lot dude! You saved me dozens of hours!
It is great. I tried to restrict using a driver after certain frame and I did it! Thanks to you.
Fantastic video! Thank you for sharing.
Nice propositions on this tutorial; kind of an inspiration to learn Python even.
*_False if var >= 0.9999 else True_*
I came up with this simple Expression for another case of Blender's UI Option switching:
I was trying to improve the Driver switch system I was using… thanks to your video, I now understand if I learn some Python basics, I can use it as Scripted Expression Type on Drivers. Then, I've came up with this simple Expression:
Of course this isn't too difficult to understand. Basically, if the Driving Bone has its Y-Axis Scale Untransformed (in principle, equal to 1.000 at start/reset Scale) or above that given threshold (0.9999), then a Bone Constraint from a Bone that contains this Driver, on its Hide/Unhide Toggle Button, is turned OFF (Hidden); else, it is turned ON (Unhidden). Unfortunately, there seem to be a glitch in which the exact value becomes unsafe; like for example >=1, = 0.9; because then, whenever the (Y-Axis always) Scale is _exactly_ on that Value, it starts to have the Bone Constraint Toggle Button going wild, randomly switching as you move the Bone around (not even Re-Scaling anything, just changing; it glitches). Thus, I found you need to get the Scale on any Value that is _not exactly_ the same as the on the Expression, therefore 0.9999; very very unlikely to drop at this Transformation Value by accident.
Amazingly helpful. Thank you!
Incredibly valuable information
I've been wondering this for while, thanks for sharing this bcuz I want to make a face rig but with shape key and i think this trick will work. I'm gonna try it later😊
excellent tip . so if we do sin(Frame/3) we will get a sin wave style lfo oscillating between the start and end value , what if wanted to do a square wave or a triangle wave or maybe a random Sample hold style lfo ?
Thanks again (I asked for advice under another video), it worked out! But seemed to me that in Blender this is true 1 (visibility), and false (invisibility) is zero. When I was convinced by an experimental example that my inverse idea of this is true, the expression worked as it should.
This might be dumb but is it also possible to chain more if statements after "else" ?
Btw love this video ! Thanks ! :)
For sure! You can stack them in one driver expression or use multiple properties to add a bunch of stiches.
😆thank you, it is very cool
Perfect explaination. Thank you.
thank you sir
This is neat. I am not a programmer but you explained it so well I was able to modify your code to give objects a level of detail property. Instead of using the switch value as the variable to drive viewport visibility, I used the camera distance from the armature bone. The line of code I typed in was "0 if switch
since your using a scripted expression the "switch" is just a variable storing the values and code, it can be called anything and would still work. Take a look at the driver variable type, in this case being single property, both share the same name "switch", if you were to change any of them you will get an error.
Thanks for the great reply Antonio! Summed it up perfectly.
@@LevelPixelLevel Not a problem, I'm still learning as well. I hope to apply everything I know to make something amazing. Your videos have been very helpful.
This is a good illustration of working with expressions in the driver. But "Disable in viewports" does not affect the rendering and therefore is poorly applicable in real animations, If I understood everything correctly.
are else-if statements possible within a driver? If so, what would the syntax be?
This is really cool and easy to understand, thanks.
Is there a way to use drivers to swap between (enable/disable) collections?
I've setup a starter scene with multiple backgrounds and am trying to figure out a top level way to swap between then since each collection holds a lot of individual objects.
Hey, I don't have a method for driving collection visibility right now. Although I'll look into it and see if I can find a way., and if I do I'll make a video.
One option might be to nest everything under one collection and use this for a toggle.
Or use another scene for the extra objects and use a collection instance.
@@LevelPixelLevel Ahh ok thanks for the quick reply. atm I am handling it via collection nesting. I did try using other scenes as groups, but it didn't make it much faster to swap between backgrounds, especially since it was like 9 scenes with around 5 backgrounds per scene, though I've shifted from that to a more modular approach.
Why is it that if i use the 'frame' variable to get the passed time, the driver f***s to work for minutes, before it finally starts working after numerous ins and outs into the Drivers Editor? I change nothing in the expression line, it just tells me for a minute or two that there is an invalid python expression, then after sufficient time wasted, it starts working.
Cool! Is it possible to put a random number in that expression?
Kind of - but it is a bit more advanced. I'll do a video on this soon.
it can use if elif else ?Seems unable to increase the elif control condition
how can I use this method in a hair particle system (hair particle modifier) ? this method doesn't work in the hair particle modifier. Any solution please?
Oh ho...! :O
and how can i do it with bones? cause this doesn't work with bones
What should I do if in the 3.1 alpha it says invalid python expression?
can this be done only on a plane for moving sprites , like set it up to scroll through the uv unwrap which has a sprite sheet , i can get it to go from stood to walking sprite and cycle back through if its still moving in that direction or change directions to change the sprites being played ?
Why did you start the script expression with "0"?
how do i put a and in the code?
is there a way to convert the ".xxx" name extension of an object into a number that can be used in a driver?
for example, an object with a name "cube.005" . is it possible to extract the last 3 characters and convert it into an integer or float?
do you know how to add driver on collection?
I have not found a way to do this - but let me add it to the list. If I come up with a method I'll create a video.
could you remade it please?
Halo, I have a question. So I have a rig and I wanted to add a feature called auto blink that allows the character to automatically blink without me needing to manually animate it. But the question is that how can I do this?
First thing you can do is choose a method for rigging the eyelid: czcams.com/play/PLbjn7kaP877uYJP4IEoj7r87qi37APhiU.html
A shape key might be a the best thing for this.
Then you can add an action constraint: czcams.com/video/5JmPFsIEgHI/video.html&ab_channel=LevelPixelLevel
This can be used to drive the entire animation with one bone or control.
And if you want to take it to the next step you can add a driver to this that is driven by the timeline: czcams.com/video/sfn1MJ3X-dg/video.html&ab_channel=LevelPixelLevel
This can be a driver that is drive by every 5 frames, set off a blink.
it doesn't works in my driver
such a cool series; many thanks
got a pair of sliding doors working using a bunch of nested if-else statements: czcams.com/video/3X7URlrtlg8/video.html
just to add, if we have a bunch of values triggering a particular condition we could stuff them into a list
for example:
0 if switch in [1,3] else 1
arguably easier to read, especially if the list contains 3 or more values
thanks again
you are a legend thank you so much, been searching for a solution for this exact problem for about 2 hours now