If Statement In A Driver | Blender Drivers Master Class

Sdílet
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....
    .....................................................................

Komentáře • 55

  • @djmnx01
    @djmnx01 Před 2 lety +4

    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!

  • @BreadcrumbMC
    @BreadcrumbMC Před 3 lety +5

    Wow I never knew you could have python logic in drivers. SO MANY NEW POSSIBILITIES

  • @metamesh1
    @metamesh1 Před 18 dny

    thanks, this is EXACTLY what i was looking for! thanks for sharing :)

  • @SleepyEngi
    @SleepyEngi Před rokem +1

    Very useful tip, much easier than having to do some separate script. Thanks!

  • @DioriteTM
    @DioriteTM Před rokem +1

    you are a legend thank you so much, been searching for a solution for this exact problem for about 2 hours now

  • @syam.k.yenubari
    @syam.k.yenubari Před 3 lety +3

    Well I am not a programmer but this blows My mind...

  • @stefanguiton
    @stefanguiton Před 3 lety +2

    Great video! Love this driver series, keep up the great work

  • @forrestgump2114
    @forrestgump2114 Před 3 lety +1

    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.

  • @MikeRadjabov
    @MikeRadjabov Před 2 lety +2

    This is very useful method, thank you for great explanation!

  • @jeffreystephens2658
    @jeffreystephens2658 Před 3 lety +2

    Excellent.

  • @rigidpartyvan
    @rigidpartyvan Před 6 měsíci

    Just what I needed!
    Thanks a lot dude! You saved me dozens of hours!

  • @HroftiHroft
    @HroftiHroft Před 2 lety

    It is great. I tried to restrict using a driver after certain frame and I did it! Thanks to you.

  • @activemotionpictures
    @activemotionpictures Před rokem

    Fantastic video! Thank you for sharing.

  • @pxy-gnomes9781
    @pxy-gnomes9781 Před 2 lety +3

    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.

  • @Yaroslav_A.
    @Yaroslav_A. Před rokem

    Amazingly helpful. Thank you!

  • @coolestardude
    @coolestardude Před 11 měsíci

    Incredibly valuable information

  • @radhinnasywanabyasa1673

    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😊

  • @sameeruddin
    @sameeruddin Před 7 měsíci

    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 ?

  • @MrGravicaper
    @MrGravicaper Před 3 lety

    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.

  • @PCgmesforever
    @PCgmesforever Před 3 lety +4

    This might be dumb but is it also possible to chain more if statements after "else" ?
    Btw love this video ! Thanks ! :)

    • @LevelPixelLevel
      @LevelPixelLevel  Před 3 lety +7

      For sure! You can stack them in one driver expression or use multiple properties to add a bunch of stiches.

  • @Lee-gx8cd
    @Lee-gx8cd Před 2 lety

    😆thank you, it is very cool

  • @zuggamasta
    @zuggamasta Před 2 lety

    Perfect explaination. Thank you.

  • @mildanhali
    @mildanhali Před rokem

    thank you sir

  • @JoseMares3396
    @JoseMares3396 Před 3 lety +2

    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

    • @antoniowilmot2637
      @antoniowilmot2637 Před 3 lety +1

      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.

    • @LevelPixelLevel
      @LevelPixelLevel  Před 3 lety +1

      Thanks for the great reply Antonio! Summed it up perfectly.

    • @antoniowilmot2637
      @antoniowilmot2637 Před 3 lety +1

      @@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.

  • @adeptussilicium2821
    @adeptussilicium2821 Před 4 měsíci

    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.

  • @8bitarmory846
    @8bitarmory846 Před 3 měsíci

    are else-if statements possible within a driver? If so, what would the syntax be?

  • @NightSpyderTech
    @NightSpyderTech Před 3 lety +1

    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.

    • @LevelPixelLevel
      @LevelPixelLevel  Před 3 lety

      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.

    • @NightSpyderTech
      @NightSpyderTech Před 3 lety +1

      @@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.

  • @Gary_Hun
    @Gary_Hun Před rokem

    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.

  • @fabbrobbaf
    @fabbrobbaf Před 3 lety +1

    Cool! Is it possible to put a random number in that expression?

    • @LevelPixelLevel
      @LevelPixelLevel  Před 3 lety

      Kind of - but it is a bit more advanced. I'll do a video on this soon.

  • @GoldCountryballs
    @GoldCountryballs Před rokem

    it can use if elif else ?Seems unable to increase the elif control condition

  • @pronatabiswas8233
    @pronatabiswas8233 Před rokem

    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?

  • @WaterShowsProd
    @WaterShowsProd Před 3 lety +1

    Oh ho...! :O

  • @Lumina-Studios
    @Lumina-Studios Před rokem

    and how can i do it with bones? cause this doesn't work with bones

  • @CharlesDanielCharly
    @CharlesDanielCharly Před 2 lety

    What should I do if in the 3.1 alpha it says invalid python expression?

  • @RTJ3DCosplay
    @RTJ3DCosplay Před 2 lety

    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 ?

  • @ScooterCat64
    @ScooterCat64 Před 6 měsíci

    Why did you start the script expression with "0"?

  • @OreoCat489
    @OreoCat489 Před 3 měsíci

    how do i put a and in the code?

  • @maggyfrog
    @maggyfrog Před 2 lety

    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?

  • @sky_tails
    @sky_tails Před 3 lety +1

    do you know how to add driver on collection?

    • @LevelPixelLevel
      @LevelPixelLevel  Před 3 lety +1

      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.

  • @adrielguedesleon555
    @adrielguedesleon555 Před rokem

    could you remade it please?

  • @no-one3795
    @no-one3795 Před 2 lety

    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?

    • @LevelPixelLevel
      @LevelPixelLevel  Před 2 lety

      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.

  • @adrielguedesleon555
    @adrielguedesleon555 Před rokem

    it doesn't works in my driver

  • @samdavepollard
    @samdavepollard Před 2 lety

    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

  • @buraqstudio0786
    @buraqstudio0786 Před 7 měsíci

    you are a legend thank you so much, been searching for a solution for this exact problem for about 2 hours now