Control Rig #4: Intro Constraints | Unreal Engine Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] all right everybody welcome back to another Asad Dev Unreal Engine tutorial We are continuing our control rig series my name is Kevin and so far we've talked about a lot of foundational stuff like Ford kinematics inverse kinematics and today we are going to talk about a very important foundational piece of rigging which is called constraints now the way constraints work is it's kind of described in the name we are going to use constraints to constrain one object to follow another object and there are a lot of different constraints that we can use which we are going to be going through today to give you some good foundational understanding of how these work now the fortunate thing is once you understand how one set of constraints work generally speaking that applies to all of the different constraints and you will be familiar just because you have an understanding of one so with that the top unreal and take a look at what we're looking at so here we are in Unreal Engine and we have a simple control rig for us to work with uh two two joints which we're not even going to worry about and we have four controls we have our ABCD control I have specifically made these to be generally speaking uh right angles squares diamonds Etc so that we can see as things move rotate and change direction what's happening now as I explained constraint allows us to bind one object to follow another object in some way if we rightclick in our event graph or a rig graph and we type the word constraint you'll notice a whole list of constraints come up we have aim constraints parent constraints position rotation and scale so as with the description that I gave you already a constraint will constrain one object to follow another one so if we're going to do that with a position constraint we are binding the position of one object to follow another rotation rotation of one object to follow another Etc now we're going to start by working with the position constraint we're going to go through constraint fundamentals using this and then we'll show you a couple of uh things to note about some of the other ones once you understand the basics of a constraint so here we are we have our position constraint now in this particular case what we're working with as a child we're not using bones we're using control controls and the control that I'm going to make follow is going to be this pink one all right that is our d control so our decol is the child now with all the constraints generally what you're doing is you're giving it a a parent a pseudo parent and so down here once you've set your control you can go ahead and open up the parent section and for the first item that we're going to constrain to we're going to constrain this to another control and the control we're going to constraint to is this Red Cube so that's going to be our a control now when we connect this forward solve up and we compile it you'll notice that nothing moves however when we move our Cube now you'll notice that our d control moves with it because it is constrained to follow the cube in position so let's compile that and let's make one other change here all right we're going to to take our position constraint and rather than a position let's do a rotation constraint all right very quickly we're going to do the exact same thing we're going to do control we're going to choose our d control and we're going to have it constrained to another control and in this case that is our a control but this time we're going to do it in rotation now you'll notice that when we compile the d control the hot pink one in the middle does not not move or rotate however when we rotate our a control the cube you'll notice that our hot pink control rotates with it if we compile we go back to the beginning now what's important to notice is we do not have a position constraint anymore I can move the a control wherever I want but the hot pink control the d control does not move it is only constrained rotationally CU that is always all that we have connected let's go back to position okay our position constraint makes it so that we can move it around now there are a couple of key features that are important to understand about all constraints so first things first there is a check box here that says maintain offset it is checked by default what that means is when the constraint is created the offset it has from its parent it is going to maintain that relative distance so it doesn't move if we want the pink control to snap to the exact same position as the red box control we can uncheck this and when we do so you'll notice that the pink control snaps to wherever the red box is now in general so basically to summarize a constraint has a child it's called an Unreal Engine and it has a parent but you'll notice that the parents are capital uh parents is plural so it could have one or more parents we'll get to that in a second and we have our maintain offset box that's pretty much it that's all there is to constraints now let's talk a little bit about the fact that this is called parents we can actually have our d control the hot pink one follow more than one control positionally all I have to do is add a new parent and in our second parent I'm going to make this a control and we could have it follow the b control which for example in this particular case is the blue sphere now at this point our d control the hot pink control is following both the red and the blue control equally the weight for each one is one and this is the next piece that is common to constraints the weight so let's take a look at this if we move our blue control you'll notice that the pink one moves but not quite 100% okay okay same thing if we move our red control it moves but not quite 100% that is because it's following equally it's following the red and the blue control equally if we change the weight of the a control to be zero it will no longer follow the a control the weight of the a control constraint is zero and now because the weight of the blue control is one it is going to follow the blue control 100% so are constraints have a child has one or more parents has the ability to maintain offet depending on whether or not we want it to or not and with the number of parents that it has you can choose to set the weight accordingly now here's the interesting thing we now have two parents let's set our weight to be equal if we do not maintain offset and we have two parents in a positional constraint and we don't maintain our offset this is going to snap to position to be halfway in this case between the red and the blue control the reason for that is the constraint is weighted equally to both the red and the blue if I change the red control to be half the weight you'll notice that the hot pink control moves to be closer to the blue control that is because the weight of the blue control is more it's greater it's one and the weight of the red control is half so depending on what your weights are set to that will determine how much this pink control follows either the red or the blue once again if we maintain our offset it is going to go back to where it is and it's going to follow based on the waiting that is here that is it okay constraints are very straightforward we're having a child follow a parent and we can do it positionally we can do it in rotation we can do it in scale now there's a couple other things now that we have this information let's go ahead and do this exact same thing except with a rotation constraint so let's create a rotation uh constraint we'll type constraint and we're going to set up the exact same behaviors let's just disconnect position for now and let's get our control and we're going to make this our d control just like we did before we're going to make our first parent be the control and the a control and then let's go ahead and create a second parent and this is going to be the b control okay when we compile that the pink control does not move because we are maintaining the offset however when we rotate our a control you'll notice that the pink control rotates a little bit not 100% but a little bit I'm also going to turn off my Snappy now if we rotate and it's the same thing if we rotate the blue control you'll notice that it gets a little bit of it however just like with the positional constraint if we set the weight of the a control to be zero now when we rotate the a control you'll notice the pink control does not move however when we rotate the blue one the pink control works with it 100% just because we set the weights now what's interesting about the rotations is when we when we uncheck maintain offset you'll notice that it did not move the reason that it did not move is because the blue controls default rotations are zero the red controls default rotations are zero and so is the pink so it's not going to change however if there were a rotational difference it would just like the point constraint snap to be halfway between or whatever the waiting happened to be so that is how we would set up a rotational constraint and we can combine them so let's go ahead and combine these so we have our weight of one and we're constraining red to blue let's do this and compile it we've maintained our offset so now the pink control follows the red and the blue control in both position and rotation by 50% or actually we need to up this weight 50% each because the weights are equal across all so when we move this you'll notice that it moves 50% with red when we rotate this it rotates 50% with red same thing with blue when we rotate 50% and so on so almost all of our constraints work exactly the same so let's take this and delete this now and let's take a look at a couple of other constraints that are worth mentioning constraints and we're not even going to cover the scale constraint it works just like position and rotation but there is an interesting one the parent constraint the parent constraint has all of the same features and aspects of the the rotation and the translation combined so we can use one constraint to do both of those things so in this particular case let's change this to control and we're going to be using our hot pink control and our first parent is going to be our well it's actually even it's actually even more interesting than that hold on let me show you the difference we're going to do and actually I'm going to undo because I want to show you the exact difference give me one second second I want to bring back my okay we're going to bring this back and let's just do one item for the purpose of this test all right and we are going to all right let's just trash all this stuff trash all this parents parents are zero okay so for this one the d control let's add an apparent and the item is going to be the a control control and the a control and same thing over here it's add the parent and it's going to be the a control contrl a Okay so we've reestablished our our constraints for rotation and position we're maintaining our offset and we're only constrained to this a control remember movement Works our our translation works but our rotation is a is a local rotation notice how this rotates about its own Center axis I want to contrast that against a parent constraint a parent constraint effective it's almost like a dummy parent it's almost like we're parenting it without actually physically changing the hierarchy so what this is going to do is if we use a parent constraint on our d control to our control for a what we're going to end up with just like the other constraint attributes if we maintain our offset when we compile this what we get is we can translate our a control and our hot our red control and our hot pink control goes with it but now when we rotate what you'll notice is it rotates around the pivot of the red control because it is basically a pseudo temporary parent that is slightly different than the way a rotation position constraint works because the rotation is just relative to its own transform whereas the parent constraint is almost like parenting to the other object without actually changing the hierarchy so that's one big difference to highlight about the parent constraint in general we love these kinds of constraints and uh we'll use them frequently and often to temporarily give controls the ability to follow another object in both rotation and position but maintain the offsets and act as if they have a new parent so that covers our translation rotation and parent constraints all of our constraints sharing generally the same attributes one last one to take a look at just because it is slightly different is our aim constraint now just as we did before we're going to go ahead and do a control and our control that we're going to constraint is our d control this is why I pick picked a pointy object for the d control because I want you to be able to see our constraint for an aim constraint what we are telling the con the child is I want you to look at whatever I tell you to and I want you to and the way we describe how you aim at the object I want you to follow is by giving you information about which access so in this particular case you'll notice that my aim aess is set to X of one y0 0 x points down towards the right in this viewport so it's towards the sharp pointy end over here on the right our up AIS is important the up Axis in unreal in this case is z up now there are different options that you can use for the up I'll explain to you why we do that in a second but first let's get to the constraint all right and now we have our Target and we can use a Target position that is something that maybe changes over time or we can use a control now in this particular case I'm going to use a control and the control I'm going to use is my a control and when we compile that you'll notice that everything snaps back to where it was right by default when we connect this everything snaps to where it was but now we are constrained so that the pink control will always aim at wherever the red control goes okay now we can also change this if we were to aim this pink control rather than at the a control we were to aim it at the b control you'll notice that it'll basically it won't change direction and the reason it's not changing direction is because we have this maintain offset here if we don't maintain the offset you'll notice that it will rotate to snap to face the blue control and then it behaves just like as if it was facing the red control so if we go back to our a control which is the red one and we don't have maintain offset nothing changes the reason being is because the red control is already perfectly aligned with the current facing of the pink control so that's why there's no change now let's talk about one other thing that is important to understand about aim constraints and that is the world up now the up Direction what you can think of is here let me help you out visualize this here a little bit what you can do is you can think of the up direction as for example this object that sits above the pink control and I'm going to uh set the offset C okay and the reason that we're doing this is if you think about it this control if the red control were to pass over it the math can get funky we don't worry about the math we just worry about the creative but I'm just letting you know math can get funky and what can happen is the constraint can get confused and it can flip so we give it an up Vector to help stabilize however the up Vector is important if we pick an up Vector that for example let's see if we can get this to flip out so our Target is a control and let's see if we can give it the C control and if that's the case um location yeah you can see how it it moves when I move my up Vector so that that affects the roll pitch and yeah it affects the roll right now is what we're on all right and so what what's going to happen is if we were to and this may be difficult to see and we may not be able to do it if we get to ah you can see it so as this red control comes up and starts to cross over where our up vectors you'll notice that the hot pink one starts to flip so it gets confused because there's limitations in math and so we use these up vectors to help stabilize that and so what we might do in this case is you can think of it as this up Vector might be parented to a different object or it could be in a different rotational space so that as for or a great example might be if we were to well let's just as we move this up and over if we move our up Vector as well you'll notice that the hot the the pink control stabilizes so now now that this up Vector has been moved apologies this will now stay stable in this range it will stay stable until we start to cross over the yellow control because that's where the axis come together and then it gets confused it doesn't know what to do so it's important to understand what the up Vector is it determines which way is up for controlling the r and depending on where it is and how it's moving relative to your aim constraint you can get some kind of flipping if it's not done quite correctly I thought that was worth potentially mentioning so let's take a quick look back through see if there's any constraints that we missed and we did not so with that that is a brief a brief but thorough introduction to the foundational understanding of what a constraint is we're going to constrain one object to follow one or more other parent objects and we can do that with all of the constraints share many many of the same attributes they all have potentially more one or more parents they all have weights they all have the ability to maintain the offsets and we are going to be using these constraints all throughout our control rig Series so it's important that you understand what they are and how they work as always thanks for checking out the channel if you dig what we're working on help spread the word let people know what we're all about thank you for everybody for being the best part of this channel which is our community we have patreon Discord don't forget to hop in Discord we have tons of people asking questions helping each other out that's great also very important a huge portion of our tutorials are in the live section because we have just about the right amount of crazy to do some of these live so don't forget to check those out those are there for you to um hopefully help you wreck the learning curve my name's Kevin we'll see you in our next control rig tutorial take it [Music] easy
Info
Channel: Ask A Dev
Views: 2,819
Rating: undefined out of 5
Keywords:
Id: 6GV7AwhohOI
Channel Id: undefined
Length: 21min 41sec (1301 seconds)
Published: Fri Mar 01 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.