Your Animation is Lying to You | Gimbal Lock Explained

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
gimbal lock is what we're going to talk about today it is a sneaky and mysterious thing that everybody talks about that you will inevitably encounter not a lot of people talk about what gimbalok is how to diagnose it how to realize that you're in it and then how to fix it solve it and avoid it in the future that is the goal of what we're doing today and I'm gonna make it easy to understand and easy to remember how to deal with it going forward sound good cool if you're new here hi I'm sir Wade and if this kind of thing is helpful for you there is a link down below to my Maya for animators Workshop it is a giant Workshop ever since I left Dreamworks Animation I have been teaching this Workshop every couple of years and at this point it's up to 30 plus hours of stuff it's everything I know how to do it's all tailored for artists to make all this technical stuff as easy as possible so that you don't have to deal with struggling against the computer you can just make the stuff you want to make so if this all sounds good please check out that link I put a ton of work into that workshop and this gimbal lock stuff we're about to cover came from there it's it's a small part of my giant animation Workshop so check it out enjoy let's talk about gimbal lock so let's start simple let me show you what gimbal lock is and how it occurs and then I'll break into all the details and what to do about it and so on right so I've got a cube I've got my rotation Now by default most animators just spin the ball or you move the individual axes or you do whatever you're going to do under the hood though Maya is not looking at the same manipulator you are this orb this manipulator is lying to you it's always been lying to you the cake is a lie and so is this orb we'll dive into that in a minute but let me show you gimbal mode we'll come back to that gimbal mode just allows me to it doesn't allow me to spin this orbital I can't do it I have to move these independently but it is a more mathematically precise way of looking at these rotations in 3D space because the computer has to treat these as one at a time and there is always a way or under the hood when you're doing all your rotations in your animating one of these might cause the other two line up with each other see how by moving the Y in this particular case I caused x and z to overlap now they both kind of do the same thing there's no longer one here vertically to go towards and away from the camera I can't spin it I can't do anything about it I mean that in a nutshell that's gimbal lock I've just gimbal locked this object now nothing's physically locked like these can pass through each other like it doesn't hurt anything in theory it just hurts you in your workflow because what happens is you are not looking at this you're looking at whatever normal manipulator ball you you have here and let me let me set a key if I you know if I take this and I go a couple Keys over I say well let's just move rotation in Z space in terms of like object mode you have a big blue line here that's rotate Z Now gimbal does not show that Z is over here but if I'm in my normal view I can just brute force it well let's just move it right I just move the one axis look at the values look at the values in the channel box they're doing all kinds of weird stuff with all three axes if I go ahead and leave that you can see that I didn't just move one axis it moved all three because if I go back to gimbal I'm now in a completely different position see how suddenly I have y as a vertical thing and then these ones are still kind of overlapping ish over here what has happened is because there wasn't a mathematical way to spin it that way it didn't work I just told Maya it's been the thing and I said well I'll figure out how to give you that pose but it has to do all kinds of weird gimbal math behind the scenes to make that happen which is why now if I take rotation X Y and Z we line them up with our our object mode and you can see which way they're supposed to point if I take X and spin it that one works if I take Y and spin it that's that's not quite lining up if I take Z and spin it that's also that's like completely the opposite of what it's supposed to be doing this is gimbal lock this is how it comes to affect you gimbalock is an under the hood behind the scenes mathematical issue with the way you've been posing your character or with the way the rig has maybe been set up for your workflow to go and it manifests as the viewport and the graph editor not agreeing on what you get and therefore the computer lying to you about what the heck to do to fix your animation if any of this sounds familiar to you you've experienced gimbal lock so a lot of people do is they end up just going one frame at a time and just hard keying the poses that they want that's not a good solution either so let's solve this problem yeah by the way if you're enjoying this so far please do the thumbs up subscribe if you haven't thanks all right so if I want to move an object in 3D space that's pretty easy right I can go up I can go forward I can go sideways cool now if I just spin the object a little bit you'll be able to see that the way that I have my Maya set up is I have the up Arrow now points upwards of the object right it's the objects of the objects left the objects right it's a little bit now skewed from the regular World from the grid you can see the grid represents my world in the world space and I can do that I can switch my translation to match up forward and right perfectly along the grid right so I can have this just go floating straight up or I can switch it to go up where the object considers up right these are just different transformation spaces I'm not doing anything in Maya differently um and I'll show you how I did that in a second but if I'm in World space and it just goes straight up and down in the world if you look at my channel box it's just doing why it's just going straight up and down because I can go up and I can go sideways I can do whatever I want but if I switch it to object space and then I go up you can see that's messing with X Y and Z because this object is all skewed and it flies that way it's like floating through space diagonally and upwards right so even though I can choose to just move the up Arrow it's still moving it through space using X Y and Z following me so far so this little menu that I'm pulling up which by the way I'm pulling this up to switch between object space and World space just like this a little bit buggy so sometimes you'll see the arrows on both or just one it's kind of weird but how I'm doing this is I'm holding down W and left click so I hold down W hold down the left click and when I release my mouse hold down left click and then release it switches um and then you can release W afterwards so so that is how I'm switching between world and object space and if I had this with a character you can see that I might move his arm through space with World space but if I want to extend his arm I might use object space to just go over it and Pull It Forward in context of the arm so it's your convenience but now same thing if I hit e and go to rotation I can go to world rotation which means I can I can spin this sideways and I can move this all around and this manipulator doesn't move that manipulator never changes no matter what I do it just stays there because the world isn't rotating it's always got the same axes so I can just spin it if I switch that to object rotation I'm holding e now so if I hold e and left click and drag if I switch that to object space rotation if I spin this now you can see that it spins with the object and no matter what I do all three of these axes will stay separate from each other they will all stay perfectly aligned with whatever that cube is pointing and technically we also have this last one on the outside this is just like a screen space rotation it's just rotating from exactly where you are on screen your camera base rotation but this is the thing that is lying to you because this isn't really what's happening under the hood this is again for your convenience World space object space it's just there for you to have an easier time to spin the object the way you want to spin it but if I switch it one more time to gimbal mode you can see that they're a little bit off like this one's kind of pointing in different directions and you can see what happens here is these ones actually move now they don't all just stay oriented the way they were they're more customizable For Better or For Worse so it's important that you knew that because really what's happening behind the scenes here is the gimbal a gimbal in this case is three interlocking Rings where each one represents an axis of motion X Y and Z roll pitch and yaw or whatever they are together they can allow you to have a 3D object be rotated any way you want now there are other more complicated ways to rotate stuff with like quaternions and all this other fancy math stuff that we are not going to talk about we're not going to touch it what we care about is that there are three axes of rotation and again under the hood another thing that you may not have heard much about is something called a rotation order we don't have to understand this super well but I need to cover it just enough so you get it rotation order if I go into the attribute editor of this object you can see that there's an option called rotate order XYZ you can actually drop this down and change it so if this object has an XYZ rotation order what that means is that X is the child of Y which is the child of Z which means that Z is the top level and X is the bottom level and Y is kind of in the middle right so if I move X by itself it's not going to be able to affect anything else it just moves X and you can see that that value is changing and it's doing its thing if I change y it's going to affect Y and it's going to affect its child X it's going to kind of come along for the ride now if I move Z it's going to affect Z and it's going to take the other two along for a ride right that is the order of which things happen here which is the reason that if I move y it's going to take X over here to Z now there's no way to completely avoid this happening you can change the order to be more convenient for how you're going to work in your workflow like maybe you need to do this all the time this is a bad rotation order but if you don't ever need to spin this Cube on the y-axis then this would be fine because if I move this then I move this I'm never going to have a problem so there's no way to never have this happen it's just a matter of adjusting things so that you don't have to deal with it now if I leave this rotated and I just grab a different one let's say zxy let's grab zxy you can see it just it changed so you can see in some cases it is just changing like where the things are and in other cases it's totally messing up the rotation of your object so this is not something that you can animate this is not something that you change throughout your shot so that's a very high level example of like what rotation orders do and how gimbals work and why these things are causing you problems now let's go away from Theory and let me show you with an actual character why we care and what to do about these things now here we've got the David rig and something I haven't really addressed is when you are working in your animating is there a right or wrong like rotation order to use the answer is not really that's it's really up to your preference if you are an animator who really really likes the graph editor or you're really trying to understand the graph editor and you want your viewport and your graph editor and your brain to all agree and you don't mind a little bit of inconvenience well then the gimbal mode might be the best way for you to work because what you see is what you get when you work in gimbal everything in the viewport everything in the graph editor and everything that you do is exactly correct because it's all math there's no viewport no convenience no well we're going to point it in the direction that we think you'd like it there's none of that but if you're an animator who likes to just take this little ball and spin it to make your poses well then you're you're not going to want to use gimbal because when you're in gimbal again you can't just spin the ball you have to do it one channel at a time if you animate an object a world space or whatever you still from time to time may want to just check Gimbal and take a look at what it looks like even if you just go right back because here's what's gonna happen David is a fun rig he's a cool rig but the problem with him is he has a bad rotation order by default and you can change it but here's the thing whenever I load up a character one of the first things I do is I just you know I move the arms down and if you're in object space or World space whatever that's fine like here I'm in object space and there's no problems I just move his arms down but if I switch to gimbal lock I am immediately met with locked gimbals I'm already in gimbalok that anything I do from here is gonna potentially cause me issues because watch if I take this arm and I rotate it down which I'm gonna do those immediately lock up now if I use his X rotation to move his arm up and I want to move his arm out I can use this one and now I might be okay right I've unlocked it that may have been fine because it locked and it unlocked and there's only one way to know and that's to hit play and see if it does anything weird but if I come back here and instead of using X I use Z and I move it up I don't have a control to make his arms come out there's there's not a there's not a thing for that so at this point I'm aware there's a gimbal luck issue and I know I need to adjust my rotation orders but again most people will never know that that's what happened so let's do an experiment I'm going to take his arm I'm going to key it here go 10 frames down I'm going to move it down we know we're gimbal locked and I can go and I can check that yep jumbo locked all right fine and then I'm gonna go 10 frames more and I'm going to back in object mode or whatever I'm just going to say move his arm up and I'm gonna have to wonder did he use X or did it use e did it use the good one or do you use the bad one I don't know I can go and I can check and say I'm still locked I don't have a way to spin his arm out to the side at this point I should but I don't so again pretending like we don't know anything let's go ahead and just do it out he goes now if I go back to gimbal here suddenly it's unlocked and we have to wonder is that good is that bad like what happened and there's only one way to know we have to hit play or we have to get to a point where we're adjusting our curves and our splines and we have to see if things are working for us because sometimes you get lucky and you might enter and exit gimbal lock accidentally and gracefully without any issues but you might enter it and stay in it or you might enter it do some damage and then leave like you never know the trick is being able to either avoid it or fix it once you've found it right now we know what our four poses were right it was out down forward and out that's what we set keys on let's look and see if it kept it that way out down for whoa okay that is not the pose we set before and then out it does do something weird and if I take if you look at the gimbal you can see that that this is about the gimbal rotation is saying but if we say okay well you know what let's go back to object like that's not what I wanted hey why is this all wonky uh I always wanted this out in front of him that's what I wanted what does that do out down forward and then out and then you can see there's this weird Arc now so even by brute forcing it you can see there's some weird things starting to happen so hopefully this is giving you a good idea of how gimbal lock shows up in your work I don't have a great example to like like look at my full animation with gimbaluck because I don't want to animate a whole shot knowing I'm going to get gimbaluck this is gonna be a nightmare so even if that'd be a cool YouTube example I don't want to be unhappy so hopefully this is you know ringing some bells and making you go oh yep yep I remember this I've dealt with this because ultimately with this rig in this situation the problem is that when I move his arm down I get gamble lock and that's what's causing my issues so let's just forget all the problems and let's see how to fix it because you should be able to take a character's arms and move them down to a very natural position and not have them lock up in my opinion that's not okay so we need to do is go to the attribute editor control a and you might need to switch to a different tab here you need to find the one that's got the the transform Matrix and you can see the rotation order of this particular rig is z y x meaning that if I move Z it doesn't affect the the other two why is the one that moves Z and then X moves all three now you can just do some trial and error to see which one you like you know switch these down and then start moving it around and see what you like that can be really tricky because you can't really account for all the Motions you're going to need throughout your shot in this particular case yzx is what I want for the David rig and the way he's been rigged so again this is not like a rule for you this is just with this rig in the way that things are aligned and how the rig was set up so if I switch this to yzx and then I will go back here if I move his arm down no problem I don't have gimbal lock if I move his arm up still no gimbalock I can even move his arm back out no gimbal lock now that doesn't mean that this is always going to work there is always one axis that will cause the other two to line up but it usually you want it to be something that you're not going to be doing as much in the case of this rig I need to be able to move his arm down that's just like a basic motion I can't have that locking things up now if I move this over you can see that that causes gimbal lock right if I move it right in front of his arm I need to be able to do that but now I'm locked so if this pose in front of him with like the arm like this is gimbal lock well there's another way to get there I just have to move his arm down and then swing his arm up no gimbal lock in the arm and then in this case to get this wrist motion that's that doesn't have to be like the whole arm twisting that's not how I get there anyway I just twist the wrist and that's that's how I would do that that's the way that I decide whether or not a rotation order is good if I can do a natural anatomically correct series of motions without hitting gimbal luck I'm happy if something super simple causes a problem then I want to change the rotation order so that that's not the case so now the Moment of Truth the thing that you all want to know now that you've seen how it works where it comes from how to kind of mitigate it how do you fix gimbal lock how do you avoid it entirely in fact well because of the whole three axis gimbal thing it is impossible to not have them like allowed to overlap that is just a 3D rotational mathematical fact that can happen hello from the editing room I forgot when I was filming this to tell you one of the easiest fixes that doesn't always work but it's the thing that you hope works if you've said a bunch of keys you've got gimbal lock and your animation is basically doing weird things the arm was keyed here it was keyed here and it's doing weird arcs to get there gimbalock is to blame and your best case scenario is to grab all of your curves in the graph editor go to Curves Euler filter and if the animation Gods smile upon you that will correct the interpolation despite the gimbal luck issues that won't always work though so that's the best case scenario and if it doesn't work well then that's where the rest of the solutions you're about to see come into place so I don't know how I forgot to mention that but there you go back to it so the best thing you can do is to check your arm rotations first and figure out a rotation order that's going to work for you and that is easier said than done because you saw that like I knew which one to click and you could trial and error it but there is a tool that can do that for you if I just go ahead and set a few quick keys in here just to make sure it's got some data to analyze and it's a gimbal I'm gonna say okay I'm getting a little bit of gimbal luck nothing crazy you can see I can I can create gimbal lock and say okay now it's a problem right so what I can do is I can take this control and I can actually use an anabot tool called selection attribute space switcher what that will do is pull up a little thingy here for a rotation order and you can see that the FK shoulder left rotate order you can see it's set to yzx that's what we said earlier and you can actually open this up and it will show you with your current keys and with all keys considered which of the rotation orders is best suited to help you with your animation and I'll just try this one and you can see that now that I'm in gimbal mode I don't have a problem so let me just jump through my different so if I jump through my different Keys you can see that they sometimes will kind of rock a little bit they'll move a little bit but it was calculating which one is the least of all the evils right which one's the the best of of the options so if you're already in the middle of a shot and you're having gimbal luck issues that's probably your best bet and I'm bought with that tool turn it on check which one and it'll switch to your rotation order for you that's best case scenario the next thing to keep in mind is don't use this ball to rotate this is a dangerous game to play because if you just start spinning this thing you don't know what mathematical choices are being made you don't know which ones X Y and Z you're just setting a pose I recommend that everyone always has the graph editor open somewhere on their computer and that you're not just using this to spin all three axes but that you are specifically either grabbing things in the graph Editor to move things or that if you are using gimbal you can move each one independently so that you can make the change visually and see the change in the graph editor so that when you have to go back later and make your adjustments to your animation and refine stuff you kind of have an idea of what you're looking at because you did it on purpose if you just spin the ball that's just going to keep the graph editor a big mystery for you also I have a whole video on graph editor stuff if you need some help there you're also more likely to run into Euler filter issues which is that thing where you might over rotate the problem there is if you have a character who you know they move into a certain pose pointing that pose can look the exact same if the curves look like this or if the curves look like this because rotations happen in 360 degrees and in the same way that a clock can be 12 noon or 12 o'clock midnight it's the same pose but mathematically under the hood it's a whole nother Octave of rotation of animation and so if you're using the rotation ball and you're constantly just spinning it you might end up in a pose that looks good but causes a bunch of visual issues to get there if you have this happen by the way you just want to go to your graph editor hit curves and go down to Euler filter that will analyze your graph editor for any big spikes in 360 degree value changes or 180 degree value changes across two curves if they're gimbal locked maybe they're each sharing about 180 degrees to get you that 360 and they'll bring both of them down the next option is something that I did a lot is just to reset your pose every time you need a new key pose so instead of just you know going around and rotating this thing for your next pose and then okay I want to go from up here I want to point across the body there instead of doing that just say all right I need a new pose I want to have it point across the body what I would do is I would just zero out zero out my rotations and I would rebuild it and I was all right whether I'm in gimbal or not I would just say all right down and I would swing the arm up and then I will rotate the arm and then I'm gonna have to use the shoulder to have it actually point across his body but to get that pose I will not just like spin the arm over here I will think about it down forward twist which usually makes life a lot easier because then your graph editor is represented by those various actions it's not just X Y and Z doing whatever they're doing it's that one of them is responsible for down and up one of them is for swinging one of them is for twisting that is how I treat my graph editor and that's how I treat my posing in the viewport and this is one that comes straight from the my workshop and my time at DreamWorks you will generally end up with cleaner curves that you don't have any confusion over less Euler filter issues less gimbal lock issues it didn't just have XYZ they were called rise swing and twist at the studio in the rigs they were designed to be used that way the last option is offset controls this is usually a more advanced one some rigs have it some rigs don't but sometimes you'll have a character who has say a hip control or an arm control that you'll do all your rotation on and if you need to use all three axes of rotation and one of them is causing gimbal lock well then they sometimes have another hidden control outside that does all the same stuff that way you could take that one problematic control and put it there keeping the other two separate from the one problematic one where you can change rotation orders and they won't really affect each other that's a less common solution so I won't talk much about it you could also technically use animation layers to do that but again that's just adding a lot of complexity where the other things I've shared are probably better answers if you're watching this video if you found this even remotely helpful please give it a thumbs up so more people see it share it with a friend and check out my Maya Workshop down below the the Maya for animators Workshop that I have created is 30 plus hours of stuff like this this is a whole section of stuff that I've tried as hard as I could to cram it into this one YouTube video but it's a lot of information it's very dense and luckily you can come back and revisit it obviously but that's kind of the whole thing with my workshop the whole thing's recorded all the information I share is is practical useful advice geared towards people who need to be animating for demo reels to get a job for whatever it is you want to do so if that sounds interesting Check It Out Below I've worked extremely hard on it I'm very proud of it it will complement whatever you are doing whatever school you're going to very nicely and if you're not going to a school or you can't afford to go to some program in some cases it may even be better but as always I'm sure Wade I hope you enjoyed this I hope it helps and I'll see in the next video [Music] foreign [Music]
Info
Channel: Sir Wade Neistadt
Views: 13,491
Rating: undefined out of 5
Keywords: animation gimbal lock, gimbal lock animation, 3d gimbal lock, euler filter, maya euler, maya gimbal, maya gimbal lock, how to fix gimbal lock, gimbal lock explained, what is gimbal lock, gimbal lock fix, 3ds max gimbal lock, blender gimbal lock, ue5 gimbal lock, what is euler filter, quaternion, animating arms, animation gimbal, character animation, animation tips, learn animation, learn maya, maya for beginners, maya animation, maya animation tutorial, gimbal
Id: XCh-yEkHPMo
Channel Id: undefined
Length: 24min 30sec (1470 seconds)
Published: Tue Mar 28 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.