Full Body IK: Procedural Dragon Animations

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hi everyone my name is andreas zuika and i'm evangelist for epic games in this video i will show you how to use the new full body iq solver in unreal engine 5 to do a 100 procedurally animated character after a short introduction into the solver used in control rig i will show you how to build animations in several layers if you want to learn more about control rig check out our website where you can also find my very first steps the logic for the walk is currently done in blueprint we use full body iq to post a dragon only with using the food locations leveraging a post-process animation blueprint we can layer several secondary motions on top we will dive a bit into physics for the tail and other dangly parts for the dragon and we will end up with adding the ability to reach for nearby applets so let's start with checking out the solver once you have enabled the control rig plugin you can create one by making a right click on the skeletal mesh which i have already done here here we have a simple starfish starfish-like character that has five limbs with four bones for each limb by enabling the display axis on selection you can see your bone orientation for this demo i colored the mesh for a better understanding of the bone axises to find the full body i key node you have to enable the plugin here we have different settings we can define the root of the chain we have effectors bone settings and settings for the server and a little bit of debug for this starfish the root of the chain is the center bone next we need effectors let's start with the left arm i already created some controls for each tip of the limb just plug in the transform and we can see it is already doing something next we need to set up all controls i have prepared that here let's see what we got so the solver is already doing a pretty good job and we can get pretty nice poses by just placing around the controls we plugged in and when we move the center it's doing this now to the general settings height duration increases cpu costs the mass multiplier affects bone resistance and here we can enable stretch you can also pin the root bone translation let's take a look at the settings for the effectors with offset alpha you wait the ability for the bone to reach the target control so with 0 the effector remains in input pose and strength affects how much this effector influences the whole keychain and now let's take a look at the bone settings let's zoom in one of the arms let's go here and take a look at this bone when we move this around here let's disable stretching for a second you can see the second bone in the chain doesn't really know what to do let's fix that so we add a new bone setting and define which bone we want to influence first there is rotation stiffness setting it to one will completely lock the bone rotation the position stiffness is doing the same but for the location and then we can lock each axis for example when we lock that now it keeps its orientation and what we also can do is we can limit it to for example between -45 and 45 and then we have this so but let's set him free again a very helpful setting is the preferred angle when we set this on the z-axis we specify how much the bone should rotate when the chain is squashed sometimes it helps to set the duration to zero because the preferred angle is done first in this way we can directly see the result of our settings and by setting it to a negative value the rotation is in the other direction so in this way we can set up the rules how our bounds should behave so the solver is doing already the heavy work you would normally do with quite a complex rig with this knowledge let's now dive and take a look at our character this is a blue dragon he has two feet a head with big eyes and a tongue and he has wings some tiny arms and a pretty long tail one of the most important things i learned in this project is splitting up your animation in different pieces so for him we will have first a control rig with the full body i key for the base pose and then we will have some animation blueprint that contains this control rig we will have physics for the tail and another control rig that drives the rotation of our spine then we will have some floppy wings again done with physics and a third physic asset for the tongue and for a little bit resisting a hand and then for the big eyes we have some control rig that does some random eye blinking and eye movement and in the end we will have a post post-process animation blueprint where we mix this all together the post-process animation blueprint has some great advantages and you can add it here to a skeletal mesh and once it's loaded you can actually enable it in all the viewports which is super handy and i will show in different occasions this very modular setup has some great advantages it is easier for debugging testing and tweaking and it also gives us freedom how you assemble it it can also be used for scalability and optimization so with all this in mind and the full body iq we just looked at let's take a look at the setup for the bass pose so for the very first step let's take a mesh that has boxes for each bone colored in the axis so here is the full body iq solver with the controls for the feet and for the head without any additional tweaking this is what we already got i'm using a very handy note here called project to parent which allows me to parent controls dynamically outside of the hierarchy so the football here will be parented to my food control the reason i'm doing this is to have the food control at the position where later my trace for the automatic fuse placement will be at my bose will follow along this is generating already pretty great results so we can imagine how this would feel like when he's walking one of the problems of an auto walk is very often they feel very without weight because the pelvis here is not moving let's fix that so here i have some additional graph i made so now if i move the feet you can see his pelvis is coming around and have a little bit of a simulation let's take a look how this is done so basically we take the z component of the both controls multiply add them up and use a verlet simulation with some settings so now the pelvis is offset and is following along when we now offset his head a little bit then we get a pretty nice result and a dynamic movement so now he would be ready to be animated in engine so i could use this control rig now and just wrap it in a level and begin to animate but as i started my journey in rigging and animating only a year ago i lack good animation skills i wanted to try how far i can get with procedural animation so now let's try to hook this control rig up with a character and add some logic for the food placement the character here is based on the character class that comes with the engine it has a scheduled mesh and a movement component to drive the controls we just made we need a left and right foot location so i made two components one is a lag and one is a leg manager so the leg manager has not much in it so basically it knows about all the legs it updates the legs each tick and it has a handy function so the food can ask if at least one foot is placed so we don't end up with all feet in midair so that's basically it let's take a look on the leg so the leg manager is updating them and they're doing three steps it's getting a target location it checks for replant and it takes a footstep so last time i made an automatic walk i got a lot of question how this works so let's go a little bit deeper here the target location is basically taking array start and array trace end um that depends on the lag position and then we have a macro here that's just doing the line trace and if that fails we do the line trace again but this time it was a longer array and if that even fails we fall back to our last target location so then we check for food plant so if this target location has a certain distance to our food position then we say we want to try to do a replanting so now the luck manager comes in handy we can ask if this is okay so if this is okay we begin doing our replant so we are not planted anymore and we save the plant start position we also say that the time since unplanted is zero now so now we take a food step so the food step first we calculate the percentage how much we have done and then we use this percentage to lurp between the plant start location and the target location and here we use curve asset so here's a curve we can tweak this later and give it more character for an ease in and ease out or whatever we want to do so but now we are just lurping between those both positions and we need a z component so the food is really lifting from the ground we use another curve here which looks like that and then we add this that component and now we have finally our food position which should drive our full body ikey and thus our whole animation and at the end we just checking if the replant is done so let's take a look how that looks like so here are some debug nodes uh the red one is our trace the blue one is our foot position and the pink one is our last plant location so this is looking pretty good with this done we now have to feed this data into our control rig and we use an animation blueprint of the character here so what this does in event graph it's checking the leg manager getting the legs and then we save the left and right foot in this moment and then in animation graph we only this is pretty simple we have only a control rig and we're feeding in the left and right foot position we just calculated so let's take a look on that control rig it's basically the same as what we have done before so we have our full body air keynote with this both project to parent nodes and then here we take the food location and now we have to drive the controls and in unreal engine 5 control rig has functions which is super handy so here we have a function that's taking the location we transfer that from world so to have it in our global rig space and then we do another trace and with this trace if we hit something we take normal using an aim mass with that upwards so that gives us a rotation and now with a location coming in from the logic and having the rotation here we now have a slope warp where the feet is placed on the surface properly so let's take a look how this dial looks like with the character so first let's add a character to our mesh here and now let's see how this looks so this is pretty convincing already without us doing any additional thing but we see two problems here first his chin is really easily sticking into the ground and our relay for the pelvis is gone so let's fix that in the control rig i made a new function that's called process pelvis so let's hook this in and take a look inside so what this is here is our relay and the movement of the pelvis so we have our weight back and now we actually want to rotate the pelvis depending if he's moving upward or downward so the chin is not sticking into the ground here i have a really handy debug with a visual debug you can nearly oh notes have at visual debug and this gives me the quad so we can see this and here from euler we make a quad so if i move this if i put a minus here or a positive here we are rotating the pelvis so this is how we can actually manipulate him and now the question is where do we get this value from so in my case what i did is i do a trace from the head downwards and depending on the distance between this and my former location i can map this to some values and that's what i did here so now when we take a look he has back his weight on his hip and it's moving upwards and downwards and when he's moving upwards he is rotating the pelvis a bit which gives us this result we have all these debug nodes and it's really handy that you can use a dot animnode dot control rig dot debug one and then it is displaying now our debug nodes which is very practical when you want to see if what you what you try to do there is also happening out in the real world but full body key is not the only feature of the engine and during this project i learned about a post-process animation blueprint so on the skeletal mesh you can add a post animation blueprint that's based on the same skeleton so i made i made that and once you you made that you have in all viewports in the engine you can enable it and you see he has already stuff going on with his tail his wings and his eyes moving so let's take a look the animation footprint here is is doing several things it looks like a lot but if we take a look at the single pieces it's actually pretty easy so we get the input pose in this case our base pose the full body i key had provided and this is operating on top of that so first we take that pose and i have a rigid body node with a tail set up in physics i will show that in a second then we cache this pose and then we use this cached pose and have another control rig here which is doing some spine movements i will also show later and then we mix this with the incoming physics and blend them by bone on the tail and over spine and this cached a spline adjustment we use then to drive physics for the wings we cache that and then we have another one with physics for the tongue and for the hands and last but not least we have one control rig that is doing the random eye blinking so that's basically it the beauty of this is now we have all the single pieces so in the moment i only want to check out one thing i can bypass everything and debug really easy another big advantage is i can use this kind of setup when i'm limited on animation budget and blend in and outer stuff depending on platform or maybe on distance with this overview now done let's take a look at different pieces and i would like to show you a little bit about the tail physics during this project i learned some nice tricks setting up the physics and i want to take the opportunity to show them to you as i might help you with your project this tale consists of 8 bones and i use the body creation tool to get some capsules and my basic setup then i went into the details of each capsule and cleaned up the data a bit so i zeroed out y and that for the location and the role and the draw for the rotation let's get now to the physic itself i set the linear damping to 1 and i wanted to have the tail to have some resistance to movement so i set the angular damping to 120 starting with 30 gave me a very good start and helped me out to find my my proper value so in the past when i worked with with physics i had always one of those problems that um this tail was of on the ground so let's boost up the gravity for a second and press simulation so you can see what i mean so that's what i normally got with with all my setups so let's set this back so what's happening here is this is a chain and the physics is pulling on the parents of the chain so i have to do certain setups so first of all in the past i went to the constraint and then i usually bumped up the motor a lot and that gives you jittering and a lot of other problems so to counter that i can actually manipulate the center of mass so in this case i move the mass up the chain back closer to the constraint which makes it much easier for the physics to deal with this and next a good rule of thumb is to make the children half the weight of the parent so here you can see if you go down this chain i decrease the weight and then i have a pretty okayish motor which is pointing a bit upwards and with this setup i have this now and this is exactly what i wanted and no jittering and it's fluid and it's doing what i want so this is perfect so now i have a rigid body node in the animation graph so here i add the acid and the next thing i have to do is changing the linear and velocity scale on all three axes tuning this made a big difference once a dragon stomped around in the world so if we now bypass everything and only take a look at the physics of the tail together with what we have done before this is what we get pretty cool so with this tail doing its work together with the base pose coming from the full body eye key next what we want to do is taking a look at the wings the eyes the arms and the tongue but before we do that we take a look at the spine because the spine you can see here is moving a little bit unnatural so when he's going rotating left or right it's staying stiff and it's not the tail is not following him and the height is not looking in the direction let's take a look how we can fix this so with the physics on the tail done now we can use this as an input post to a new control rig so now we need to know in which direction to lean so i have this little function here that's taking the current and the previous rotation of the character doing a delta between that interpolated and then we have a value which we can feed into our small control rig because we can mix different control rigs together so this control rig is only doing the spine movement so when i now adjust the incoming value you can see this is what we get so let's take a look how this is done first i clamp the value between minus one and one just to be sure and then i we have to take a look at the hierarchy so first the tail is going in this direction after the pelvis and the spine is going the other direction so we do two iterations one over the tail bones so what we're doing here we're taking the lean amount multiplying that with the value for our rotation in that and multiply this quaternion with the incoming bond rotation and then we use the weight so the for loop has a ratio which is the value between zero and one we ill over evaluate over a curve and that is what we use as a weight and that gives us the opportunity to model how this curve looks like and then we do nearly the same for the spine up to the neck in this case we are using an interpolation node which gives us opportunity to have different values for interpolating between decreasing and increasing values which gives us a nice head movement so when he is looking left or right so and this is a really really small piece and when we have this now all together we can bypass the rest and take a look how this looks like on our small clearing here so this is pretty awesome this was a moment in the project where i was super super happy because now the tail movement has physics and we have control over his lean and we can blend this together and this looks really like character vivid and full so yeah with this done now let's take a look at all the other parts because basically we have talked about the basic setup so we have another physic asset here for the wings so that's following the same kind of rules it's a little bit more floppy like that and then i have a third one which is here and that has all the rest so in my case this has the arms and the tongue so the tongue is like that and the arms a little bit resisting so like you would expect from this kind of dragon so we just mix this in and with similar settings we have seen before with a tail and then last but not least he had really big eyes so i had to do something with the eyes because he was a bit lifeless without doing anything with the eyes so he he or she is blinking and when we take a look in the control rig i am here using some randomness and accumulate time and the seamless curve so it's it's not perfect but it's it's doing its job for now so that's what i do for the blinking and for the eye movement i have something similar on two different axes so after a certain time it looks like he's looking in another direction it is not it as i said it is not absolutely perfect but for me that that was pretty nice proof how you can separate all that pieces and this is how it looks all together now so his tongue moving his wings moving his tail following him he's blinking and it looks like he looks out for stuff and with this modular setup we can use all the pieces in different areas for example we could use the control rig for the eyes even when we animate him in engine that's pretty nice so now let's come to an important topic it is well known that blue dragons love red apples which gives us an opportunity to show how the full body ikey solver can work to reach positions in the world let's go first back to our very first control rig we made because i want to show something with the animation blueprint as you can enable it in all the viewports we can also do it here in the control rig editor and if i do so and add a little bit of a jaw control you can see his tongue and all this physics is working on top what i'm doing here this is pretty nice so in this moment when i did that i got the feeling i have a little creature on my computer which i'm playing with instead of a convoluted complicated character setup that's hard to work with so this was really really fun and something that gave me quite some joy so when we want to take a look at the epi let's assume this is the apple and when i move it around we want to look at this direction so we can use an aim node so the location of this uh we can take its target and if you are like me sometimes having trouble with the aim mass it's a very good trick to first zero out the secondary axis and then focus on what is the proper axis for your primary ones so once we have that the rest is a piece of cake we have a transform and we can use this in this case i'm not directly putting it onto the control which you would expect but to a space and the control is within the space which gives me now the opportunity to animate on top so i have now an aim and i can i can do some adjustments which now goes into the full body i key that's it so this is what we now need to do and let's take a look at the control rig we are using for him so here's the aim node and here we have the rotation which we feed into the control for the head we can also take the world position of the apple transfer it from word and then interpolate the head between that so he's reaching in that in that direction so if if we do so um we need the apple position so the apple itself uh here it is we have a sphere and when the player enters the sphere we're calling a function that's on the dragon so the dragon has this function it's not doing much it's actually saving the position of the apple saying we are looking at it and then we're using the animation blueprint to feed this into the control rig so this is what we got it is pretty close but it has one issue as you will see in a second so he's looking at it but he is actually not stopping looking at it even if this is really hurtful so how do we fix this to explain a bit what we need to do i made a small control rig to explain that so imagine that as a green line here is our dragon's direction and the box is where the apple is so depending on the distance we want to decide if we want to take a look at the apple or not and that's easy we can just calculate the distance between both points do a remap between one and zero and then i'm using this to change the color of this line so when it's getting red we don't want to look at it anymore so that's already good for the distance but not for the for the angle so how do we do that when we look uh to the back and we can use the dot product for that so in this case the forward axis here is y so that's what we use there and then we normalize our direction and if we now feed this into our color thing and set this to zero then when it's blue when it's in this direction on particular it is zero and on the back it's turning red because it's negative so in our case we put 0.5 which is in this direction that gives us a result we want so this is this is all okay for for bending the neck and if we now combine the distance and um and the dot product result we now have a weight that depends if we look in the right direction and if it's not too far away so this basic mass i have here in the control rig so let's like plug this back in and then instead of have a convoluted graph i made a function which is here which do the mass and using this weight and then i do an accumulate lerp so he is moving towards that target i'm giving him and with this done we now have a 100 procedural animated dragon who loves red apples i personally like a lot when he's getting close to the apples that are in the tree because that pose he's he's making looks like he's desperately trying to grab them with his tiny hands so here is one of the use cases how you could use full body ikea and how you can approach a very modular setup in unreal engine again i learned a ton in this project and i have to thank some people aaron langmead for taking my ugly bass mesh and making it the gorgeous cute dragon kieran who's the engineer for full body a key for his guidance and help with the logic for the autobook jeremiah and craig from the control rig team for being always so patient with all my questions special thanks to charles anderson who taught me a lot about character physics and last but not least jordan walker for the awesome volume network clouds i could use you can find more information about the animation features and full body ikea on our website also check out the demo of the early access version of unreal engine 5 welly of the ancient where the ancient uses a lot of the techniques i have shown here there is more to come we are developing editors to make it easier to create full body iq setups or the ability to create global functions and control rigs to share them between different rigs as someone still new in this field i'm very excited to see what developers out there will do with this thanks for watching and see you next time
Info
Channel: Unreal Engine
Views: 33,827
Rating: undefined out of 5
Keywords: Unreal Engine, Epic Games, UE4, Unreal, Game Engine, Game Dev, Game Development
Id: Z8eqaFG7lZQ
Channel Id: undefined
Length: 29min 12sec (1752 seconds)
Published: Tue Aug 24 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.