Animation in Unreal Engine: Adding Life to Your Story | Webinar

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
MATT: Hey, everyone. I'd like to welcome you to this webinar on animation tools in Unreal. While we don't cover every tool that is available to us today, we will be looking at some great techniques to liven up your architectural visualizations without the need to create complex systems, such as vehicle physics and character AI. Some of the topics we're going to be covering include basic material animations, moving vehicles around using Blueprints and the camera rail, animated characters, flocking birds with Niagara, cloth simulation, and finally adding wind to trees and grass. Now we also have the privilege of having the tools chef team with us today. And they'll be demonstrating their Atoms Crowd plug-in for populating our map with animated people. Let's get started by looking at some simple material animation techniques that can help us liven up the map that we're working with today. MATT: We're going to animate two different objects here. First of all, I've got a fountain. And we're going to set it up so that it looks like the water is flowing down around the structure. And then I also have some traffic lights towards the end of the cinematic. And we're going to make those lights blink. Let's go ahead and start with the fountain here. So we'll select it, and then open up the Material Instance. And from here, we'll open the parent material. Now looking at this material, the best way to animate the water effect is going to be to animate the normal map. You can see that the normal map is currently being driven by this normal from height map, which uses a black and white texture map. And then we're editing the coordinates for that texture map using a UV edit node. And it has a lot of different inputs here, but the only one we're really concerned about is going to be the transform input. So I'll press P on the keyboard to create a panner node. And then we'll go ahead and drive that into our transform. Now the panner node needs coordinates, time, and speed. So for coordinates, we'll just use the regular UV coordinates. So that's U on the keyboard, and then connect that into coordinate. For time, we need to right click and type time. We'll drive that here. For speed, we need two values. If you look over under the Properties, we need speed X, and speed Y. So I'm going to drive it with two scalar values. So I'll hold 1 and click to get my two scales. And then I'll connect to the first scalar to an append vector. And it will add the second scalar to that append. And then we can connect the append up to our speed. Now to make this all usable in a Material Instance, we need to convert these two scalars to parameters. We'll call the first one speed X, and then the second one speed Y. And we need to make sure speed X and speed Y are set up. For the time being, let's go ahead and put in 0.5 and 0.5. OK. So hopefully, you can see the rippling effect as it moves down on the sphere here. We'll get a little closer so you can maybe see it better. So right now, this is at a value of 0.5 on both the X and Y speed. Obviously, we could tweak this. We could make it slower, we could make it faster. But we're going to go ahead and go with this as we obviously are limited on time today. So let's go ahead and look at how to adjust the street lights so that they flash. All right. This is my street lamp here. I'm going to go ahead and load up the material. So it's a very simple emissive based material. We just need to use a sine wave essentially to have it flash on and off. So we'll go ahead and use our sine wave, because our sine wave will allow it to go between a state of 0 and 1 using a very smooth curve. And then the sine wave expects time. So we'll go ahead and plug-in the time. And then from here we're going to divide. This will allow us to control the speed a little bit. We're going to go ahead and leave it at a default value of 2. And then we simply need to multiply this by our emissive lerp up here. So we'll go ahead and create a multiply. And let's connect the lerp to that actually on the top and our divide here. And then we can plug that into emissive color. Now this works clearly. We've got a nice blinking light. But it's not very bright. In fact, if we look in the scene, you can see it's very dim. So let's go ahead and add one more node to make this a little brighter. And that's going to be a multiply node right here between the divide and the second multiply. And we'll go ahead and add a scalar here. And we can convert this to a parameter. And we'll call it brightness. And it will set the default value to 50. Now obviously, we could create a Material Instance here. But we're just going to go ahead and use the master material. And there you go. You now have a blinking traffic light. So here's a truck that we have in our scene. And we're going to animate it driving down the road. The track is separated into the important parts. So here's the main body of the truck. And then we have four wheels. But we need to go ahead and create a Blueprint inside of Unreal that makes use of these objects. So I'm going to right click, and choose Blueprint class, and then actor to create our Blueprint. We can just call it BP underscore truck. Now when we open this up, we're going to need to add all the parts of the truck. Now they were just imported in using Datasmith as they are here. But we want to use the body and the wheels inside of our Blueprint. So inside the Blueprint, we're going to drag the body into the viewport here. You can see it's rotated strangely, but we'll fix that in a moment. We also need to go ahead and drag in one of the tires. And we can see the tire is properly linked underneath the body, as it should be. And now we can go ahead and position the tire so that it matches up with the axle. So in the viewport, we're just going to drag the tire into place, get it lined up nicely, and then obviously in this case, we're going to need to rotate it 180 degrees as well. So there's our first tire. Now we're just going to need to duplicate it and create our second, third, and fourth tires. OK. So there are a lot of ways we can animate the truck inside of Unreal. We could use Blinds, or some other technique. We're going to use the Camera Rig Rail. So this object is designed for setting up cameras that are able to dolly on a rail. But we're going to use it basically kind of a Spline Guide for our truck here, because it's a very easy way to create this kind of animation. So using the Camera Rig Rail, we're just going to align that under the truck so the beginning of it kind of matches up with where our track is positioned. And now, we're going to drag out the spline point at the end of that rail until we get it to a position that we want. Now we can right click and add another spline point in the middle of that. And this will allow us to drag the endpoint further out. And then we can make adjustments to the middle point as well to create a curve. Now these are bezier a spline points. So we do have endpoints that can be adjusted to also adjust the shape of the curve. So we'll go ahead and continue adding spline points as needed, dragging everything out, until we get the path shape that we want. OK. And from here, we're going to go ahead and add the truck to the rail. To do that, we need to parent it to the rail in the World Outliner. Let's go ahead and call this the truck rail. And from here, we'll simply drag the truck onto it, and that will parent it to the rail. Now, with the rail selected, if we change the current position on the rail, we can see the truck animates on the rail. However, we need to also lock the orientation so the truck now rotates based on the direction of the rail. You can see the truck's still a little crooked there. So we can fix that simply by rotating the track itself. So we'll select the truck, and then rotate it so it's lined up a little better. And now it looks a lot better as it animates on the rail path. Now there is a problem with using this technique. And so far, it's basically that our wheels are not animating as it rolls on the path. You can see as I drag it on the rail here, the wheels are not spinning. So we need to do a little work inside of our Blueprint to make those wheels spin. OK. So to get our wheels animated, let's open up our Blueprint here. Now in the Blueprint, we're going to use a timer to automatically update where the truck is every second. But first, we need some variables. So the first one we're adding is called distance traveled. That's going to be a float. And it's going to store, obviously, how far the truck has traveled. And then a second variable we're going to add it's going to be called last location. We're going to set that to a vector. And that will store the truck's last known location. And we're going to update this location every second. We're going to do that by pulling off of Event BeginPlay, and creating a set timer node. And it's going to be set timer by function name. The function name we want is Event Tick. So we're going to be firing Event Tick every second. From here, we want to put our time for one second. And we want to set it to loop. So this is going to keep happening over and over. We're going to grab our last location using set. We're going to set it off of the timer. And to set the last location, we need to get a reference to the tire. So we'll drag pick up tire one into the viewport here, pull off of that, and we'll do a search for World Location. And we want to get the World Location. Now we can plug that into our set last location. So every second, we're getting the last known location of the tire. All right. So now, we're ready to start adding the nodes necessary to rotate the tire. We're going to rotate it based on the distance traveled. And we can get a distance traveled pretty easily. And we can basically get a vector length by comparing the last known location with the current location. So we'll pull the distance traveled variable into the viewport as a set, so we're setting it. We're going to set it to the current world location. So we'll go ahead and pull off a world location, and we're going to do a vector minus vector. Because what we want to do is we want to subtract the current location from the last known location. So we'll pull last location into the viewport here, connect it to our minus vector here, and now we're getting the distance traveled based on our last known location and the current location. So we'll pull off of that minus and create a vector length. And this tells us how long that vector is from point A to point B. So now from here, we're going to pull off of the return value and create a float plus float. And we're going to add the distance traveled to that vector length. So it's continuously updating, making that vector longer and longer, obviously, as we move. From here, we'll pull that into our set distance traveled. And that gives us how far we've traveled so far. Now we can use this information to calculate the rotation of our tires. But first, let's go ahead and update our last known location off of this. We'll go ahead pull in another copy of the tire, just for neatness sake. We'll pull off of that, and again, get the world location. And then we can plug that into our set last location. So now we have both the current distance traveled, plus we know what our current location is. So let's go ahead and pull off of that set now. And we're going to do a search for relative rotation. And we want the relative rotation for the pickup tire. So we'll go ahead and select that. And that gives us a set relative rotation node. Now we also want tire number two. Let's go ahead and drag that in. And we can plug both of these into the target. We're going to right click on that new rotation, and split the struct into the X, Y and Z components. From here, we'll pull off of the distance traveled, and we'll plug that into the Z. So it will rotate on the z-axis, basically the axle. Let's go ahead test it out and see what happens. So the tires are doing something. It looks like they're rotating. But they're also reversed. So let's go back into our Blueprint and fix that. And here, we need to select our set relative rotation, and change the Y rotation to 180. And then we'll test again. And that should be fixed. There we go. Now the only problem is that they're rotating in the wrong direction. So they're rotating as if the truck was going backwards. So we'll go back into our Blueprint. And what we need to do here is simply multiply our distance traveled by a negative value of 1. So we'll do multiply float by float. And it will set the second value here to negative 1. And we can plug that into our Z rotation, and give it a test again. All right. So let's look at how to work with the Sequencer tool inside of Unreal to create cinematics. So rather than use the level Blueprint to make this truck move along the path, we're going to use a Sequencer so that the track moves based on whatever shot that we're in. To create the sequence, we need to right click in the content browser, and go to animation. And we'll choose level sequence. We're going to call this Master Sequence. This sequence is going to contain all the various shots. Now, in order for it to be usable in the level, we need to go ahead and drag it into the scene as well. Let's go ahead and open up our Master Sequence. And we need to add some shots in here. To add shots, we simply click on the track button here. And we'll add a shot track. From here, we can begin adding our shots in. Let's go ahead and click this Plus Shot button. And we'll create a new shot by clicking on Insert shot. And this is going to save our shot. And the shots will be sequentially named based on the other shots we've created. And it's going to put it in a subfolder called Shots. So now that I have my initial shot, we can go ahead and populate it with a camera that animates. And we're going to focus on the truck. Let's go ahead and look at how we can add a camera, and animate that camera, as well as animating the truck along its path. We'll go ahead and double click the shot to enter it. From here, we need to add our camera. So I'm going to-- I've already got a camera lined up. So I'm going to click on the track button again, we're going to click on actor to sequence. And I need to search for Cine Camera Actor 5. And we'll select that. Now I'm going to minimize my window here. And I'm going to click on the little camera icon next to Actor 5. And when I do that, it sets the viewport to that camera. So we can see that I have a nice shot here of the main building. And we're going to basically have the truck roll past the camera here. Before we do that, let's make a few quick adjustments to our camera here. We're going to set our aperture to 1.2. And then our focal length, we're going to leave that. And we'll go and leave the focal length and the focus distance as they are. And if we open up Transform and Location, we should see the current values here. We can go ahead and key frame the location. And if we're intending to change any of these camera settings, we can go ahead and key frame those as well by clicking these little buttons here to key frame. Now, to add the truck animation, we need to add the rail. And we can do that by going to our world outliner and typing rail. And here's our Camera Rig Rail. We're going to drag that into the Sequencer. And now we're going to click the little plus button here to add a track. And the track we're going to want to use is current position on rail. So we'll set a keyframe right here at frame 0. And then we're going to move to the end of the track here. You can either type in the value 150, or you can use this button down here, which will automatically jump to the very end of the sequence. From here, we're going to set the value to 1. And let's go ahead and scrub the slider. Now you can see the truck goes by. But it might be a little too fast. So instead of going that fast, we're going to change this value. So we're going to jump to that last key frame, change this value to 0.5, and we're going to position it in a different location. So we're going to drag over the key frame to select it. And we'll move that key frame further out. So let's go ahead and drag this over to about frame 500 or so. OK. We'll jump back to the beginning. Let's go ahead and move this off screen for a moment, and hit Play. So we can see the truck now moving quite a bit slower as it moves across the screen. Now, you'll notice that the tires are not spinning. That's OK, because these tires will only spin when we actually simulate. They're not going to spin properly when we're just running the sequence in the editor like this. So in order to get this working where our tire spin, let's go ahead and set it up so that our Sequencer is played at the beginning of the level when it's loaded. We'll jump into our level Blueprint. And we need to get a reference to the Master Sequence. So we'll do a quick search in our world outliner for master, select that. And in the Blueprint, we can right click, and click on Create a reference to Master Sequence. From here, we're going to pull off of that, and do a search for play. And we're looking for Play Sequence. There we go, Play Sequence player. All right. And now we simply need to plug-in our Event BeginPlay to the input of our play node here, and compile that. So now when we hit play, we should see our sequence automatically playing, and then the truck is moving through the camera, and the tires are properly rotating. All right. So now that we know how to do that, we can go through here and animate all these other vehicles on the road, the ambulance, the bus, and so forth. We can use the exact same technique by using a Camera Rig Rail and Cinematics to create the animated effect. But let's go ahead and move on now. And let's look at how we can also add some people to our scene. Unreal has an incredible amount of tools for doing character animations. It can do State Machines to have characters change their state, such as from idle, to walk, to run, and so forth-- all sorts of wonderful tools for creating these animations, as well as AI tools, and so forth. In this case, we want to work more simply, however. We're not going to be using the AI system navigation stuff, or State Machines, or anything like that. We're just going to drop in some canned animations to help liven up our scene a little bit. And that's easily done simply by dragging a character into the scene. So let's compose a shot here. I want to have two characters talking to each other, and enjoying the late evening sun. And then we'll create a camera, and then we can obviously animate that camera inside of a sequence afterwards. So let's go ahead and drop our characters. And I've downloaded some simple animations here. The first one I'm going to use is called Mobile Wait. And we'll just go ahead and drag him into the scene there. And then the second animation I'm going to use is called Talking. And then let's go with Talking 2. All right. So now, we simply need to position these guys a little better so that they look like they're talking to each other. Let's go ahead and clear this out. And then, we need to set up our location and rotation values. I've already set some up ahead of time. And I'm simply going to copy and paste those. So I'm going to right click on Location, and choose Paste. And-- whoa! We were really close on that one. And then I'm also going to copy the rotation. So again, I've copied it from my little text pad. I'm going to right click Rotation, and choose Paste. Ah. Again, we're very close on that one. And let's also do the same thing for Talking 2 here. I'm going to need his position. And I will paste that. And then his rotation. Once again, will right click, and choose Paste. All right. So now they're facing each other. They're in a good position there. OK. Let's go ahead and simulate this now, making sure that we choose simulate, and then click the Play button. OK. So there we go. We've got our two characters talking. It's obviously very simple to add in an animation like this simply by dragging it into the scene. So from here, we can go ahead and set up our camera inside of Sequencer. So in order to add a camera animation focused on these two characters, we need to create a camera first. So I've lined up where I want my shot to be. I'm actually going to make some adjustments to the field of view, and so forth. But this is where I want my camera to exist. So in order to create a camera here, I'm going to click the Viewport options button, go down to Create Camera here. And I'll choose Cine Camera Actor. All right. Now from here, we need to make some tweaks using the camera settings. Now this is a physically based camera, so it's very accurate. We're going to go ahead and leave all of these settings to default. I'm going to however change my manual focus distance to 805 centimeters. And then we're going to set our F stop, which is current aperture, we'll go ahead and set that to 2. And then the current focal length, which is set to a value of 11 right now, we're going to set that to 80. And you can see that, because I have the camera selected, the shot is here on the bottom-right of the viewport. So we can kind of see what's going on. But for a better perspective, we can click on the perspective button, and then go down to the camera that we just created, Cine Camera Actor 6, and now we can see it in the viewport much larger. So from here, we might want to go ahead and move the camera out a little bit using the basic viewport controls, until we get the shot lined up a little better. That shot works for me. Of course, we can press G to hide all the game objects. All right. So we've created our camera, and we've lined it up and set all of the camera settings how we like. It's got some nice depth of field going on, very shallow, and a nice lit scene here. But let's go ahead and add a little touch of animation in a sequence. So for that, I'm going to go to my Cinematics folder. And we'll open the Master Sequence. And we need to add a second shot in here. So we'll go ahead and click on the Shot button, and we'll choose Insert Shot. And this will be Shot 6, because I've already got quite a few other shots created. OK. So we've got our shot. Let's go ahead and move this shot by simply dragging it to the right. And then we can double click the shot to enter it. Now in order to add our camera, there's a couple of ways we could do it. We could obviously right click Choose Actor to Sequencer, and search for that camera, or we could go back to our World Outliner or here, select the camera-- so it was Cine Camera Actor 6-- and with the camera selected, we can now right click in our sequence, actor to sequence, add Cine Camera Actor 6. OK. So let's make sure that we are on frame 0 of this shot. And here, we want to add some key frames for our camera. So we'll go ahead and add a keyframe for the aperture, the focal length, as well as the focus distance. Let's go ahead and open up transform and add key frames for location. All right. So this is our starting position. And we want to basically kind of zoom out. So let's go all the way to the last frame here. We could do that using this button down here on the very bottom. And now we need to make some changes to our camera settings here. Now we can manually type in the settings here, or we can drive it using the viewport. So I can come in here, as long as the camera is active, I can right click, and I can make some tweaks to the position of the camera. And you can see the changes there. And if we were to create the key frames on those, we'll go ahead and rewind here and hit Play. Now we can see our camera animation. Now that's not exactly where I want it to be. So let's go ahead and make some tweaks here to the camera's settings. So we'll go back to our location key frames at the end here. And I'm going to type in some values that I like. All right. And then, for the Y, I'll put negative 438. And the Z, we're going to put it negative 37. And we're going to leave the aperture, and focal length, and all that, as it is. And now let's also select all of our key frames, and then right click and choose Linear, so that we don't have any easy in or easy out on this. And then we'll save that. OK. So let's go ahead and play this back now, and see what we've got. OK. So we've got an odd motion there. It's not exactly what we wanted. So we can fix that pretty easily. So we're going to go ahead and make sure we're on the last frame here. And then we will adjust that z-axis value. That should work. And now, if we rewind and hit Play again, we get a better motion. Now let's go ahead and jump back up to our Master Sequence using the bread crumbs here. And now, we can see we have both of our shots. They're not playing right now. That's because we need to enable the shots right here at the top. Clicking on that little camera icon, and now we can see both angles. So there's our first shot with the animated truck. And then we also have our second shot. So we've added quite a lot of animation to our scene. But it still lacks some people. I could go around the map, manually dropping in more animated characters to liven things up. But that would take quite some time. Also, making them walk around the map without bumping into obstacles, or each other for that matter, would require a lot of work. However, this is a great time to introduce Daniel from Tool Shifts. Daniel is going to take us through their Unreal Engine Adam's Crowd Plug-in, which will allow a much easier and faster workflow for adding in fully simulated crowds, and thus adding some more life to our scene. Daniel, you're up. DANIEL: Thank you, Matt, for the introduction. So before we start populating this environment, I would like to spend a few words to describe the work that I've already done on this map. As you can see here, we have a navigation mesh which is based on this mesh here, which is a combination of all the sidewalks and footpaths. Also, I've copied some of the mannequin assets into this folder. So we have the mannequin skeletal mesh one of its materials. And those are two versions that we're going to use later of the same material. Also here, we have two animations. I have modified these two outside of Unreal, because there is a small issue on the right shoulder. With all the mannequins animation, we're using them with Atoms. This should be testing in Unreal 4.26. But anyway, all the other animations that you can find on the marketplace, like the ones from the Paragon character, work fine. And the same also supplies to the animation from our Agent bundle that you can download for free from our website. Another thing that I've done is I've already set up these two animation sequences so that they can work with Atoms, and with that I mean attach these asset user data called the Atoms Anim Clip User Data to these animation sequences. This data basically holds some properties that are needed by Atoms in order to play these clips, these animations. As you can see here, have a start and end frame, loopable state. And I'm not going to go into details here. But if you want to know more, you can check out our YouTube channel, where we have a video where we explain how to set up your animation sequences. So of course, I've done the same for the walk animation sequence. If we use our own animations for the ones coming from our own Agent bundle, all that data is already set up. So you don't have to do anything there. OK. So before we can start populating this environment, we need to create a couple of Atoms assets. So the first one is going to be an agent type. I'm going to click on the skeletal mesh, and then I'm going to go under the Atoms Crowd menu, and then click on Create an Agent Type. Select a destination folder. And as you can see here, now we have two assets. So the first one is a variation asset which acts as a container for skeletal meshes. So as you can see here, we have the mannequin skeletal mesh. It just saved it, and this asset is referenced by the agent type. And then we've also referenced the mannequin skeleton, and we can also assign a state machine. I'm going to create one now. So I'm going to go in here, select the two animation sequences that I created previously. I'm going to click on create a state machine. I'm going to select the same destination folder. So if I go here, now we have the state machin asset, and Atoms created two states or one per animation sequence. I'm going to connect both of them both ways. So we can go both from idle to walk, and walk to idle. And as you can see also, Atoms are assigned a unique ID for the idle and the walk. So the idle is ID 0, and the walk is ID 1. We're going to use these ideas later during the simulation. OK. So now, I'm going to assign the state machine. I'm going to set up the capsule. So the radius is going to be 30. The half height is going to be 80. And then Transition Z going to be 100. OK. So now we're done with these assets. I'm going to close this window. And I'm going to drag and drop an agent group into our map. I'm going to create a grid layout. I'm going to assign our agent type. And I'm going to just increase the grid size a little. And I'm going to also assign the ragdoll behavior. So this one basically creates the collisions for our agents. And if I show the collisions, we see that the agents have collisions. So the setup basically was successful. So we can now start populating the environment. I'm going to delete this agent group. Now I'm going to create a new one. For this example, we're going to use a mesh scatter layout, which basically takes as input a mesh. So I'm going to use the same mesh that we used for the navigation. I'm going to provide the same agent type. And I just want to create more agents, so I'm going to use 800 iterations. And I'm going to set up the radius, so that they are not too close to each other. So there's going to be-- I just set it to 200 and 300. So now, if I press Play, we have our agents. But they, of course, are not moving, because we haven't assigned an animation to them yet. So let's select the agent group, attach the state machine behavior, set the state to 1, which is the world state. I'm also going to assign a height field that you can use directly navigation mesh, and is that takes care of their terrain adaptation. And I'm going to set the state set on agent creation only. So basically, these will make sure that this state is only set when the agents are created at the beginning of the simulation. OK. So now they're working, but they are ignoring their navigation mesh. So let me attach a navigation behavior module. There are a lot of properties here, but I'm not going to go into details. We have videos on our YouTube channel explaining how to use this module if you want to know more. Just briefly-- so I'm going to activate defined target point on agent created, which will make sure that each agent will find the target point within this radius when they are created. And then also, I'm going to find a new target point of reach, which means that whenever the agents are reaching their target point, then they're going to find a new one, and they're going to go towards that. I want to make sure that the max turn angle is as a high value. So it's going to be 100. This value basically is the max turn angle that the agents are allowed to use when they're turning. So if this value is too low, whenever they are trying to follow the navigation mesh, they're going to end up in the bushes or in the streets, because, basically, they are not turning enough while they are following the navigation mesh. So I'm just making sure that this value is enough so they can actually follow properly the navigation mesh. Finally, I'm going to set a target radius to 500. I'm also going to allow partial path query. And I want to also enable separations so that they can push each other away a little when they're close to each other. So I'm going to press Play. Now our agents are following the navigation mesh. But as you can see, they will be intersecting with each other-- see there-- because we haven't set up the collisions yet. So let me again attach the Ragdoll Behavior. And if I press Play, now when they are close to each other, they will push each other away. So there are other ways to achieve this. Of course, this is just a quick fix that we could use avoidance. We support [INAUDIBLE] and algorithm. We're going to also improve our avoidance by adding new algorithms in the future. And also we're going to make sure that this kind of setup is easy to do, so with just a few clicks. Another thing to now is that because Atoms is so flexible, it's also quite easy to import simulation data coming from other softwares. So for instance, we have a feature where you are actually able to import the simulation data coming from Mass Motion, and then export that data from some Mass Motion as a CSV, and then import it into Unreal, and then use it with Atoms. So basically, Atoms will read the data, create the agents, and follow the simulation data coming from Mass Motion, which is quite nice. OK. So now, another thing. We want to randomize little the states of the agents. So we're going to use the State Picker. And the State Picker what it does is, after a certain time has passed, it will change state for your agents. I'm going to set the random factor to 0.6, which randomize it a little more. I'm going to set the timer between 300 and 800. So their timer for each agent will be between these two values. So they will have a random value between 300 and 800. And then also, I want to make sure that whenever they enter this state, so they will actually go from walk to idle when this timer elapses. They are going actually back to walk after another timer has passed, which is this previous state timer. So I want to put like 100 and 300. And now I press play. We see our agents, after a while, they will stop and be idle for a little bit. And then they will start walking again. So you see there, an agent stopped. There, another one. And then the agents will start walking again. Let's see. Yeah. There. Great. So now, what we want to do is also, we want to customize the look of our crowds a little. So what we can do is we can use the per instance metadata feature. So first thing, we need to attach a custom metadata to our agents. So I'm going to call that Color and this is going to be a vector, and I'm going to assign a random value to all our agents. So, select, randomize-- and then as you can see now all the agents have a different value. I also need to tell Atoms, so to the agent group, that basically we have to pass that value to the material. So if you go in the Atoms agent group, there is a per instance metadata section. You can add the name for that metadata. And now this value is being passed to the material. Nothing has changed yet, because we have to, of course, use a different material. This is one of the two materials that I've created earlier. So as you can see here, you can use the particle color to read the first four floats so that we pass to the material. You can pass up to 20 floats. And the first four are, again, read by the particle color. So I'm using just the particle color to multiply the value of the body color. So I'm going to select a skeletal mesh. And I'm going to assign this material. And as you can see now, all our agents have different color. So if I press Play, you see our crowds, each agent, has a different color. This is just one of the usages of the per instance metadata metadata feature. We could use those values that are passed into the material to change texture, or do other things. OK. So final thing, we want also to activate ray tracing for our cloud. So what I want to do is I want to make sure that our agent group is visible in ray tracing. Then what we're going to do is we're going to use the hero promotion. So once again, you can select the agent group, and there is a hero section down here. So you can promote all the agents through here. But this is not advisable, especially if you have a large crowd, because you're basically just going to fill your GPU memory, and it's going to overkill it. So what you can do is like, you can dive this promotion with the metadata. When I say promotion, what I mean is that we're going to promote the agents from regular Atoms agents to actual skeletal meshes that can be used with ray tracing. So as you can see here, I use this metadata for setting up this promotion. Now I need to basically change that metadata during the simulation. You can change these in different ways. But I've already created a Blueprint that will take care of that for us. So this is a custom behavior Blueprint. So it's one custom Blueprint that we have created for Atoms. We have override functions, which are basically hooks during each stage of the simulation of Atoms. So here I'm using the unique frame. I'm iterating through all the agents, getting their positions, making sure they are all within a distance from the player. And if they are within that distance, I'm activating that hero metadata. Otherwise, I'm just setting it to false. So if we want to use this behavior, what you have to do is you have to drag and drop it on the agent group. And as you can see here, all our agents have already changed. And they're back to their default color for the mannequin. This is because they're not actually using the proper material. Because if use these hero promotion, you need to use yet a different material, which I've already created. So if you want to use the material for both the regular agents and also the skeletal meshes, you have to create this color parameter with the name Hero, basically we'll output a value of 0 1. So if this values 1, we're getting the color metadata, otherwise we are just getting the particular color as we did previously for the standard agents. So what I want to do now is I want to select the skeletal mesh. And I want to attach these material. I'm going to click Save. Now, nothing has changed. What we have to do if you want to see this change, we have to select, again, the agent group, and click on Refresh agent group here. So you see now, again, our agents have different colors. And now if I press Play, you see that now the agents have shadows. And this is all for me. I'll pass these back to Matt. Thanks, everybody. MATT: Thanks for showing us the Adams Crowd Plug-in, Danial. Definitely makes the workflow a lot easier. So there's a few more things I'd like to show you guys before we end the webinar today. I'm going to show you how to add a few more atmospheric touches to the scene. We're going to look at adding in some animated foliage, as well as using Niagara to add a flocking bird effect. But before we do all of that we're going to also take a quick look at how to add animated cloth to the scene. And this is great for things like flags and curtains that blow in the wind. We can easily add some cloth animation to our scene for things like flags, and curtains, and so forth. To do that, we need to go into a 3ds Max, or whatever tool that you're using. And I've got a basic flag shape that I've created here. The important thing is that the pivot point on my flag is right at the top. I'm going to have the flag hanging down. And then on top of that, if we go into wireframe mode, you can see the flag is made up of quite a few polygons here. And this is important in order for the cloth simulation to function. We need to have some vertices for it to function on. So once we've done our flag correctly, we can go ahead and export it as an FBX file. We'll choose Export selected, and in the Export selected window, we'll choose FBX. And I'm going to go ahead and export it into a folder I've created here. And we'll call it SM underscore flag. And we can leave all the export settings default. Inside of Unreal, we'll need to import the flag we just exported. So we'll click on the Import button, and browse to the flag FBX file. In the import options here, we just need to check skeletal mesh, and nothing else really. We can click Import. And now we'll go ahead and open up the skeletal to mesh flag. In here, we'll set the material. So we'll go ahead and just give it a basic material here from the Engine Content. After selecting the flag, we can right click and choose Create clothing data from section. And we'll just go ahead and leave everything here default, and hit Create. Now we'll select the flag again, right click, and choose Apply clothing data, and choose the new clothing data we just created. After that, we'll click on Activate cloth paint. And then here in the clothing tab, we'll click on the SM flag clothing data. And from here we can start to paint. Let's go ahead and change our brush size and our paint value. We'll start with paint value here. The lower this value, the grayer the paint job will be, and then the less influence the simulation will have on that area. So we'll go ahead and set it to 100 so we have maximum effect. And we'll lower our brush radius down to something smaller. And we'll paint the entire flag white, except for the very top where it's supposed to hang from, because we don't want that to simulate, all right? Now we can simply save our cloth. And then we can drag the flag into the Viewport. Line it up where we'd like it to go. And now that our flag is in position, we need to add some wind. So we'll go to Place Actors, and then search for wind. Under here, we want wind directional source. So go ahead drag that into the Viewport. And then we need to rotate it so that the wind is going in the direction we want it to go. All right. So on the wind directional source, we need to specify the strength, speed, and gust amount, as well as radius. I'm going to get the strength to 5, and then the speed to 0.5, 0.1 for a minimum gust amount, and 0.8 for max gust amount, and I'll set radius to 5. All right, let's go ahead and simulate this. And we can see our clothing, our flag I should say, nicely blowing in the wind. Another trick up our sleeves to add some more animation in life to our map is to add wind effects to the foliage in the map. And that includes grass, bushes, flowers, trees, whatever the case may be. And we're going to look at two different methods in this case. We're going to look at a simple method using a material expression nodes that's built into Unreal. And we're also going to look at a little more complicated method. Both methods make use of material nodes. Let's start with the simple method here. We're going to select this plant. And then we're going to go to the Material Instance. And then in here, we need to load up the Parent Material. OK. So in this case, we're going to be making use of the World Position Offset input of our material. This is going to allow us to create some vertex animation. So to do that, we're going to right click, and we'll search for simple grass wind. And we'll go ahead and plug that in now to our World Position Offset. And we're going to need to populate these four input values here. We're going to need three scalars and a vector 3. Let's go out and create our three scales. And then we'll create our vector 3, holding 3 on the keyboard. And we'll just plug all of those guys right in. Now in order to make this easy to work with, we're going to go ahead and convert all these into parameters. Right click, convert parameter. We'll call them exactly what their inputs are. So Wind Intensity for the first one, and then Wind Weight, and Wind Speed, and we'll call this one Wind WPO, for World Position Offset. Now I'm going to set these default values all to 1. And we'll set the default value for our WIND WPO vector node here to red. You can see already what it's doing to the material here. It's basically wobbling around the leaves and stuff. So they look like they're kind of blowing in the wind. OK. Looking at our bushes here, clearly, it's not looking very good. There are some things we need to do. And there are some issues here as well. You may not be able to tell, but it's actually duplicating the mesh. Now we can go in and correct this very quickly. And that is because of Ray Tracing. We need to enable the Ray Tracing feature to evaluate the World Position Offset. So to do that, let's first go ahead and select all of the different copies of this bush in the scene. We'll do that holding Shift E. And now we have all of the different copies of that same bush. And then over on our Details panel, we're going to do a quick search for Eval. And here we go, under Ray Tracing, evaluate World Position Offset. We want make sure that that is enabled. And now we don't get that duplicate of each mesh. Now we just need to deal with the obvious animation issues. So for that, we'll jump back over to our Material Instance. And we're going to enable wind intensity, wind speed, and wind weight. And we just need to go ahead and bring these values way down. I going to bring wind intensity down 2.5. Wind speed, we'll go with 0.2. And wind weight, we'll also bring that down maybe something like 0.2 as well. So you can see now that we get a lot more subtle of a wind effect there. And we could obviously speed it up, slow it down, whatever we need to do here, to get the look that we're going for. But I'm just going to go ahead and leave it at this because of time limitations. And let's look at the second technique now for creating animated foliage. Our second option is a bit more complicated to set up to begin with. But the effects are really spectacular. And that is to use Pivot Painter 2. Now, due to time constraints, we're not going to be able to walk through the entire process step by step. We're just going to kind of do a high level overview of how you use Pivot Painter 2. And then we'll take a quick look at a final example that we can actually get from the Unreal Engine Content Examples project. So Pivot Painter 2 comes with a script component for 3ds Max that allows you to render out texture maps that will store pivot information for the different elements of your foliage. And this pivot information will then be used to create a very realistic wind effect inside of the material in Unreal. So in order to get started, you first have to set up your foliage-- in this case, we're using a tree-- so that the pivot painter can properly get the texture information it needs. That requires you to set up your tree, in this case, so that each major element is its own piece. So we start with our trunk. And the pivot on the trunk is at the bottom where it should be. And from here, after the trunk, we have our main branches. Now on the main branches, we want to make sure that the pivot is not at the bottom of the trunk as it is in this case, but basically at the bottom of the element. After the main branch, we then have our sub branches. And each one of these needs to be broken out as a separate element, again, with its pivot at the bottom of the branch. And then finally, after that, we can have our leaves. And again, each segment of leaves on one of these minor branches needs to be broken off into a separate element. So once you've got all the pieces broken off-- let's go ahead and hide the leaves for now-- you need to attach them to the element above it to the parent. And this is easily done using the Link tool. So we could select this main branch, click on the Link tool and max, click on the branch and then drag to the trunk in this case. It's going to bring up Pivot Painter 2's 3ds Max window. And it comes with a bunch of extra tools that we're not going to be covering, obviously, for time's sake. But mainly, what you want to do is simply to click the Process, the selected object hierarchy. It's going to save out two textures. Now when you're exporting the tree, obviously, you want to select the entire tree, and go to File export, and choose FBX with export selected. And we'll go ahead just call this Tree. And we'll leave all of the settings at default. Now back inside of Unreal, we need to import everything. So we will click the Import button. And we can see here we have an EXR and a TGA file. So we'll need to import those of course. And we'll also need to import the Tree. So inside the import options here, we want make sure skeletal mesh is unchecked, and combined meshes is checked. The next step in the process is to create a material. The first thing we need to do is setup our material to make use of material attributes. So under details we'll click that. And now, we also need to create our material attributes. So let's go ahead and search for material attributes. And we want to make material attributes. And then from our make material attributes node, we need to do a search for Pivot Painter. And we'll use this Pivot Painter 2 foliage shader. And then we can plug that into our material attributes for the tree material. And then from here, we'd simply create all the usual base color metallic, opacity, and so forth. And so now we'd want to create a Material Instance. And then when we open our Material Instance, you're going to find wind settings 1 through 4. And these settings will allow us to apply different levels of wind using the texture maps. So if I were to go ahead and select this position and index texture, and X vector, and X extent texture, I can then plug-in the textures that we imported. And once we plug-in our textures, we can then come in here and adjust all of the different values for controlling the wind speed, and so forth. So here, we are inside of the Content Examples Project, which you can get off of the Unreal marketplace, or the Learning tab, I should say, in the Epic Games launcher. And here we can see an example of some of the things that Pivot Painter can do. If we look here, we've got a very simple example of foliage wind. Here, we have showing how you can make your trees and grass grow. And we can even build objects over time. So this is all done with vertex animation using Pivot Painter 2. And we have two trees here. We've got one that has a very gentle blowing wind on it, and then one that has a stronger wind. And all this, again, done with Pivot Painter 2 and Vertex Animation. So rather than completely build up a tree using Pivot Painter, I'm just going to go ahead and grab one of these trees, and drop it into our project. And that's done very easily. If we select the tree and then browse to it, we can now right click on that asset, and then go to asset actions, and then migrate. And then that's going to grab everything that is related to that tree. And we can specify the project that we want it to migrate to, and simply select the folder. So now, here we are back inside of the project we've been using today. And we can simply drag the migrated asset now. It's going to be found under Example Content, Script Examples, Pivot Painter 2, and in Static Mesh. And we can just drag that into our scene, and have the Pivot Painter tree as it was in the content examples. So I think you can see that the options available to you inside of Unreal for animating foliage are pretty robust, and can create a very nice effect. All right. So next up, we're going to look at, very briefly, how do you use the Niagara system, which is Unreal's particle and effects system, to create a flock of animated birds here flying around our fountain. Now keep in mind, there are a few limitations here. First of all, when we're using this technology, because it's using some vertex animation to flap the wings, currently, we can't use Ray Tracing. You can see with Ray Tracing translucency on, we get that duplicate copy of the birds, just like we did with the foliage. So if we turn off that, and set it back to Raster, we can now see that we're not getting that duplicate animation. So just keep that in mind if you want to use an effect like this, currently, the World Position Offset animation on particles is not supported with Ray Tracing. All right. So let's look at it real quick. We're I going build a walk through the entire process. But I'm going to give you just kind of a brief overview of how it's put together. So in order to create our bird flock, the first thing we obviously need is our bird here. And we also need to set up his wings so that they can be animated with vertex animation. So to do that, we need to make sure that in our UV channels-- here we have channel 0. That's the diffused channel. We also need channel 1. And channel 1 is specifically just the bird wing. And we're going to use a gradient map so that we can animate this wing flapping up and down. OK. And so here we are inside of the material. Now in order to flap the bird's wings, we're going to use World Position Offset. Just like we did with the vegetation, this is going to allow us to do some vertex animation. And in order to do that, we're going to use a Gradient Map. And this Gradient Map will be making use of UV channel 1. Now from here, we're just going to multiply that essentially by the blue channel, which is the z-axis. Right now, there's no flapping occurring, and that's because we also need to multiply this by a sine wave. So we go ahead and add time. And then we'll plug time into our sine wave. And then we can plug our sine wave into this multiply. And now we have our bird animation. Now remember, if we didn't have this section down here with the gradient, and we just plug this into our World Position Offset, you can see that the entire bird is flapping up and down. So without this section down here, we can't control where the flapping is occurring. Now to create a Niagara effect, will simply have to right click and go to effects. And we want Niagara system. We're going to create an empty system. So in here, we don't really have anything yet. But this is our Niagara system. And we need to add an emitter. To do that, all we had to do is right click and choose Add emitter. And we're going to add an empty emitter. So now that we have our empty emitter, we need to begin setting up our particle effect. The first of we want to do is set up the type of particle effect. In this case, we're going to use a burst. So we want spawn burst instantaneous. And we're going to set the spawn count to the number of birds that we want in our system. So let's go and set that to a value of 20. Next up, we need to specify the emitters shape. And we'll do that by clicking on particle spawn. And we'll search for location. Let's go ahead and use a sphere location. You can see the particles there kind of spawning out. But they spawn out and then they die. So let's go ahead and make sure that our loop set up to not be infinite. We want it to fire off once. So we're not going to keep spawning birds. And then we'll go ahead and select our particle update. And we want to make sure that once the birds spawn, they don't die. So we can open that up here, and we can see kill particles when lifetime has elapsed. We want to uncheck that. So now our particles are being created, and they live forever. And we don't create any more than the 20 that we initially created. Now from here, we don't want to use Sprites, we want to use our mesh. So we'll go ahead and click render. And we're going to add a mesh renderer. And for the mesh renderer, we're going to want to add our bird. So for our bird mesh, we're going to go to the content browser, and we'll simply grab that and drag it into our particle mesh. And now we have our birds with flapping wings. But obviously, they're not rotating around, or flocking, or anything like that. So our next step would be to begin adding forces, and other things like drag, so that we can begin to create this animation that we want. Now we just don't have time to go into detail on all that today. So instead, what I'm going to do load up the already finished version. And I'm going to just briefly kind of walk you through the rest of the steps. OK. So we're now inside the final version of our bird flock here. And we're going to look at all of the different forces that we can apply. And you're going to find all of these forces under Particle updates. So if you wanted to add these forces, you'd simply click the Plus button next to Particle update. And you can search for Forces, and you're going to find all of the different Forces here. So the first force we're going to add is Curl Noise. Now you'll notice when I turn this on, they just kind of all disappear. And that's because the birds are coming right out of the particle emitter, and just flying off in all different directions without anything to control them. So in order to slow them down, we need to add the Drag Force. So you'll see when I enable Drag, now the birds are a little less crazy. They're flocking a little better. They're not just flying off into oblivion. But they're also not pointing in the direction that they're flying. So in order to do that, we need to make sure that on our mesh renderer, we change the facing mode to velocity. And so now, the birds are all flocking based on which direction they're flying. So for instance, if I back to Drag, and then I change the Drag value here, which is currently set to 40-- let's put it to something like 10. You're going to see that they just fly off a lot faster. They have less drag. Let's go ahead bring that back up to 40. And we can also control the rotational drag in the same way. So once we've got that all set up, we can now add a Vortex Force. And if we enable that, you're going to see that this basically makes the birds all kind of fly around in a circle as if there's a center point of a vortex there controlling their motion. Selecting Vortex allows us to make some adjustments to how strong the vortex is. So if we bring this down to say 10, you can see that it's hardly noticeable at all. But if we pump this up to something really high like 100,000, you can see that it's having a really strong effect. They're flying around like they're in a tornado. Let's go ahead and bring this back down to 6,000. And we get the effect we're going for. Now one thing you may notice is that the birds are all flapping at the same rate, at the same time. The great thing about Niagara is it can talk back and forth between Blueprints, as well as materials. So we can send data from Niagara to the material, we can send data from the material back to Niagara, and so forth. So we're going to do is we're going to pump some data into our material that will allow us to control the flapping so it's more random. Each bird will have its own flappings, so the timing won't all be exactly the same. So to talk to Niagara from our material, we're going to go ahead and just get rid of this time and sine wave here that's controlling the flapping. And instead, we're going to add a Dynamic Parameter. And then we can plug this parameter 1 into our multiply here. So we're going to be controlling the randomness of the flapping using this first parameter. And we'll go ahead and call that Parameter Wing Flap. OK. That's all we need to do in here. Now we can jump back to Niagara. So back in Niagara, the last thing we need to do is we need to create a new Dynamic Material Parameter. We've already created one here. Again, that would be done from Particle update. Now when we select the Dynamic Material Parameter, you can see that wing flap was automatically added. Right now, it's set to a value of 0. So we're not getting any animation on our wings. If we set it to 1, that puts the wings all up. Negative 1 would put them all down. What we really want to do is control this with a sine wave. So we'll click the little arrow here next to it, and type sine. We'll add that in. And so now we're getting the basic wing flapping animation. But it's still not random yet. So now we want to animate this period here. So it goes anywhere from say 0.5-- so they're flapping very quickly-- to a value of 1-- so it takes a little bit longer to complete the flap. To do that, we're going to click on Particle Spawn. And we're going to scroll down and select a new or existing parameter. So with this parameter, when it click the plus button and we need to add a float, so we'll select float. And then we can rename this. We'll call this Bird Flap Float. And we're going to change it to-- instead of a single value, we want to randomly go between two different values. And to go between those values, we need a uniform ranged to float. And the values we're going to go between is going to be 0.5 and 1. All right. So now that we've set this up, we need to do one more step. We'll jump back over to our Dynamic Material Parameters. And for the period here, we need to change that to our float, which was called Bird Flap Float. So looking at the birds here, we can clearly see that they're not all flapping at the exact same time, or the exact same rate. The last step would be, of course, to create a Blueprint that we can place our Niagara system in. We'll call this BP underscore birds. And then, opening that up, we need to add a Niagara component. So we'll search for Niagara. And we want the particle system. And then, of course, in the Niagara particle system, we need to drag our Niagara system. And there you go. So now, we can actually use this Blueprint. We can drop that into our scene. And we can use that to maneuver or position it wherever we'd like it to be. All right. So let's go ahead and see our final cinematic. So we can see here our first shot with the animated truck, as well as some cloth sim. Both our first and second shots have animated foliage and vehicles, as well as characters, and the Tool Shift's Adam's Crowd Plug-in's. And then we have our flocking birds, and our animated material. Another shot of some characters going about their business. And then, the final shot, again, with some animated cloth, some animated vehicles, as well as an animated time of day change. All right. So that's going to do it for today. That's all the time we have. We've covered a lot of ground today. And I hope everyone was able to pick something up that will be useful to them in their workflow. However, if you'd like to continue learning more about animation techniques, you can always go to unrealengine.com slash online learning and get tons of free courses there on all sorts of topics related to Unreal Engine, including animation. You can also check out some of our other YouTube videos related to animation by going to the Unreal Engine 4 YouTube channel. So at this time, we're going to go ahead and open the floor up to live Q&A. We'll stick around for, oh, 10 or 15 minutes and answer any questions that you guys have that we haven't already answered during the webinar. Otherwise, thank you for coming. And I hope you enjoyed the webinar. And we'll see you next time.
Info
Channel: Unreal Engine
Views: 156,739
Rating: undefined out of 5
Keywords: Unreal Engine, Epic Games, UE4, Unreal, Game Engine, Game Dev, Game Development, Atoms, Atoms Crowd, Tool Chefs, animation, material animation, animated crowds, Blueprints, animated people, animated birds, cloth simulation, Niagara, flocking birds, Unreal animation, animation effects, camera sequencer, physics, animation tools, archiz, architectural visualization, character AI, vehicle physics, wind effects, camera rails, atoms crowd plugin, cinematics, learn, tutorial, webinar
Id: IDNi0plxIXE
Channel Id: undefined
Length: 62min 41sec (3761 seconds)
Published: Wed Oct 21 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.