How to use drivers in Blender? | Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hello welcome to my channel in this lecture we'll learn how to use drivers in blender drivers basically are the way one object to affects another object for example you can make an object's location affects another object's rotation drivers can be applied to too many values in blender for example you can make a switch which affects a lamp's power now let's go over how the drivers works there is a cube and gear in the scene when the cube moves on the z-axis we want the gear rotates on the z-axis at the same time it means we are going to make this cube location affects the gears rotation firstly let's select the gear and press the n key for the side toolbar let's find the value we want to be drive we want the gear rotates on the z-axis so we need to move the cursor over the z-rotation value let's right-click and add driver from this menu now we have pop-up menu at the top we can see the driver property is z rotation for the gear let's go down and select the object which will drive the gear let's select the cube now let's select driver variable type as z location as you can see z rotation property has become purple color it means this property has a driver now now let's select the cube and move it on the z-axis there we go let's split the viewport window and switch to driver editor let's select the gear we can see a list of selected objects that we have added drivers to we have only the gear object that has a driver right now we call this channel let's left-click on the z-rotation channel and select let's hover over the mouse on the window and press the home key so we can see the animation curve now we call this f curve we can add other property also with the gear selected let's go over the y location property right click and add a driver now when we move the cube on the z axis the gear will rotate on the z axis and move on the y-axis at the same time also it will have two curves in the driver's editor we can delete drivers to do this go over the property you want to delete right-click and delete driver we can edit this f curve and change the gear's rotation rate the x-axis represents how much the cube's z-location has changed the y-axis also represents how much the gear's z rotation has changed now these dotted lines converge at zero it means the cube location still at zero therefore the gears rotation also at zero point let's select the cube and increase the z location one unit let's select the gear again as you can see the vertical dotted line currently shows us the location of the cube it intersects the curve at this point we call this point keyframe we have two keyframes in this curve we can edit them let's select this keyframe and press g to move we can also press r to rotate we can also edit them with handles just like a bezier curve we can also lock editability these keyframes by pressing tab key if we follow the horizontal dotted line from this keyframe to left we can see how much the gears rotation has changed so this graph tells us that one meter changing of the location of the cube causes 57.3 degree rotation of the gear say we want the gear to rotate slower as the cube moves up and down to do that select this keyframe press g and move it down select the cube again and move it on the z-axis as you can see the gear is rotating slower now if we move this keyframe up the gear will rotate faster let's select this keyframe and press shift d to duplicate move the new keyframe down a little bit now what does the new curve tell us it tells us that the rotation direction of the gear will be changed after the cube reached to 1 meter on the positive z axis let's select the cube and try it there we go we can also change interpolation type of the curve to do that press a key and select the all keyframes then right click and choose any interpolation type let's switch to linear interpolation mode as you can see it gives us sharp and straight lines between the keyframes and it allows the gears rotation direction is changed sharply and suddenly let's select the cube again and try it but if we switch to bezier mode the change of the direction will be smooth and slowly if we switch to constant mode the gear rotation will be sudden at the keyframes we can also change the interpolation type for each keyframes individually to do that let's select the keyframe and change the interpolation type as you have noticed the curve extends forever it means as long as we move the cube on the z axis the gear keeps rotating we call this linear extrapolation we can stop rotating of the gear before and after the keyframes to do that let's go to the channel menu extrapolation and choose constant extrapolation there we go the gear is rotating only between the keyframes let's delete the z rotation property driver and add y location driver for the gear [Music] in this case when we move the cube on the z-axis the gear will move on the y-axis let's press n key to open side toolbar click on the drivers tab we can access driven and driver properties here in this example the input variable is the cube z location the output is the gears y location at the top of these tab there are driver types firstly let's go over the scripted expression this allows you to use a math equation to affect the output the equation can be specified under expression the input variable is named var 0.0 is starting position of the gear so output value is computed adding the variable value to the starting position of the gear for example if we set the cube c location to three meters the gear will move three meters on the y axis now let's set the starting point of the gear to 3 meters in this case output value will be 6 meters we can also use all math operators in the expression let's switch the operator to multiplication in this case the final driver value will be 9 meters and the gear will move 9 meters on the y-axis when we use the scripted expression we actually don't need an input variable let's delete the input variable and clear the expression box let's type in 4. in this case the gears y location will be 4 meters let's set the animation frame to 10. let's type frame an expression box so the gears y location will be equal to current frame let's set the starting frame to zero when we play the animation the gears will move along the y-axis if we want to slow the gear down we can type in divided by 4. there we go let's delete the driver then select the cube and clear the location let's press shift d and duplicate the cube now select the gear again and add a driver for the z location property let's go over the driver editor and click on the z location property click on the drivers tab let's switch the driver type to average value let's select the first cube c location as input variable now let's add another input variable change the driver variable type to transform channel let's select the second cube c location as input variable now select the first cube and move six meters on the z axis as you can see the gear will move three meters on the z axis it is because our driver type is average value it will give us average value both cubes let's select the second cube and move it 12 meters on the z axis as you can see the output value will be 9 meters now if we switch to some values the sum of the both cubes will be the final driver value let's switch to minimum value as you can see the lower cube c location is used as the output value for the gear but if we select the other cube and move it below the other cube the gear move down with it maximum value also works just like minimum value but the gear uses the highest cube c location this time let's select the gear and add a driver for the z rotation then go to driver editor select the z rotation property transform channel allows us to use the cube transformations like location rotation or scale as the driver for the gear's rotation let's select the cube as driver object let's switch to z rotation and rotate the cube on the z axis as you can see the z rotation of the cube causes the z rotation of the gear let's switch to average scale as you can see scaling of the cube causes the z rotation of the gear let's switch to y location select the cube go to viewport display and enable the axis let's rotate the cube on the x-axis 90 degree as you can see the local y-axis of the cube points up let's switch to local space select the cube press g and y to move on the y-axis as you can see the location of the cube doesn't affect the gear's rotation let's press y key again to switch to local y-axis there we go when you move the cube on the local y-axis it affects the gears rotation let's switch to world space again let's add a uv sphere firstly let's select the cube and then select the sphere press ctrl p and make parent the sphere to the cube now select the sphere and move it on the y axis as you can see driver object's parent also affects the gear rotation let's select the gear and switch to transform space let's select the sphere again and move it on the y-axis as you can see the parent object doesn't affect the gear this time it means transform space ignores the transformation of the parent object but the transformations of the child object still affects the gear rotation we can also use the transform space with armatures we have a armature consisted of two bones bone one is parent of bone 2. let's select the gear and add a driver for z rotation then go to driver editor select the z rotation channel press n key to open side toolbar click on the drivers tab let's select the armature as driver object now let's choose bone 2 and set the variable type to x rotation let's switch to transform space now let's select the armature and go to pose mode select bone two and rotate on the x-axis there we go bone two affects the gears rotation but if we select bone one and try to rotate it it won't work let's go back to object mode and select the gear again delete the z rotation driver let's add z location driver instead let's switch to rotational difference let's select the bone 1 and bone 2 as driver object now select the armature and go to pose mode let's select bone two and rotate it as you can see the rotational difference between these bones will drive the gears c location the rotational difference takes into account rotation on all axes it will simply compare how close to objects rotations are to each other let's select the gear and add zlocation driver go to drivers editor and switch to distance let's choose cubes now select the one of the cubes and move around as you can see the distance of the cube's origins is the final driver value so this distance between them drives the gears c location finally let's talk about the single property input variable this allows you to use custom property values as the input it can be very useful for controlling multiple things at once we can see custom properties all over the blender firstly let's add a custom property let's select the gear go to object properties menu scroll down to custom properties click on the add button to add new property the property has a name and value this value can be used for different things now we will use it for drivers let's click on the edit button and change the name as gear driver we can also change minimum and maximum values of the property let's set the maximum value to 10. then click on ok now let's hover over the z rotation of the gear and add a driver let's go to driver's editor click on the z rotation channel press n key to open side toolbar then click on the drivers tab let's switch the input variable type to single property now we can choose the object that is property firstly let's choose the what type of property we have added in this case we have just added property from object properties menu then let's select the gear now let's select the data path to do that let's go over the gear driver right click and copy data path then go to data path press ctrl v and paste data path now when we change the gear driver value the gear will rotate on the z-axis it is very useful and handy because we can use one custom property to change multiple values for example we can use this one property to drive the gears rotation and location at the same time let's hover over the z location of the gear right click and add a driver let's click on the z location channel switch the input variable to single property choose the gear as target press control v and paste the gear driver path now when we change the gear driver value the gear will rotate and move on the z-axis at the same time if it doesn't work click on the update dependencies button drivers can be really too complex because so many combinations and connections can be made with them in this tutorial we have tried to lecture basics of the drivers thanks for watching see you in the next tutorial
Info
Channel: MK Graphics
Views: 13,905
Rating: undefined out of 5
Keywords: blender drivers, how to use drivers in blender, blender drivers tutorial, blender drivers expressions, blender drivers editor, editing F curve in blender, blender driver frame, blender bone drivers, custom properties and drivers, how do you make a driver in blender, how do I animate driver in blender, blender 3.0
Id: O6lSSGPhb4U
Channel Id: undefined
Length: 22min 9sec (1329 seconds)
Published: Sun Dec 19 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.