UE4.27: 2 Groups of Crowds Cheering 01
Crowds cheering system in Unreal Engine 4.27. Demonstrate the random animation montages and cheering trigger.
The video demonstrates the random animations playing in the crowd and also there are triggers to activate blue team crowd cheering and purple team crowd cheering. The trigger can either be keyboard, mouse, OSC, or any protocol that supported in Unreal Engine. It's very easy to control the crowd in a production shoot.
Skeletal Mesh Iimilations
There are quite a few features and limitations in this system that should be mentioned. The first one, character. In order to have a better production environment the same type character should share the same skeleton (i.e., Tall & Skinny and Chubby & Short are two different types, so they should have two skeletons.) and all characters should have LODs. The system is trigger by animation blueprint which means the animations are given by animation blueprint. Therefore, the same type character should use the same animation blueprint to run the animations. In this case, I only have one type of character. So, everybody is sharing the same skeleton and animation blueprint.
Rows and Columns Follow Curve
The second thing is the rows and columns are following curve segments' normal. Which means the column number will not grow when it's at a higher row. And when the segments are defined, the columns are defined. The image on the right shows the problem of this method.
I create a spline and get the spline length divide by a given number, then I'll get a distance between each neighbor number. An easy math, if I want to control the distance between each neighbor then I can receive the number of columns.
Length / Segments = Distance -> Length / Distance = Segments
Once you get to control distance and segments then it's very easy to make rows and calculate the positions. And rotations are rotation of the distance along spline.
In order to get the positions, we need to set origin for each point. Each point has its own 3d transform pivot point, but they are all associate with the spline. The position is following this method: Nx(Spline), Ny(Spline) stands for the normal vector of a point on the spline; x1, y1 and z1 stands for the real world transform location; RDistance stands for the distance between rows; NRow stands for Number of row; RHeight stands for height between rows.
X = x1 + Ny(Spline) * RDistance * NRow
Y = y1 + (RDistance * NRow) * Nx(Spline) * (-1)
Z = z1 + (RDistance * NRow) * RHeight
This method can create the rows which has exact same number of columns and has the same vector for each row. However, the real world doesn't arrange seats with the same method. If you have a better idea how to calculate the positions, please let me know!
Random Agents
The third feature of this system is randomly assigning agent into one of the two teams. I first create a skeletal mesh array to store the random agents then make a branch for team A and team B. And after that we can assign the loop index to module 2, therefore we will get random team A agents and team B agents from each loop.
Empty Seats
The last feature is keeping seats for important characters. I added a condition to give a control of skipping some index to create agents which will leave the empty seats. Therefore, the animators can animate the key characters on those seats. Also, there's a random empty seat checkbox to toggle if the shot needs to have some random empty seats instead of full of crowds.
Optimization
The optimization is still in progress, this workflow is using skeletal mesh components and blueprint actor to trigger multiple animations running on engine time. It is quite expensive running up to 200 agents on UE4.27 on my PC. For empty scene, it can run around 50 plus FPS with dynamic animations and great blend in montages. At this point, I have not tried to reproduce the project on UE5 yet. Though the idea is creating a seamlessly and random animation clips for crowds. And compared to VAT, skeletal mesh is still better with blending animations and mesh itself has much more detail and dynamic look.
Last Update: November 14, 2022
Software: Unreal Engine 4.27
OS: Windows 10
Specs: RTX 3080, AMD 3900x, 64GB RAM
Assets:
Basketball Court - Sunrise Studio
Agents & Animations - POLYGON - City Pack