Active Ragdoll
When the Project got started, we knew that we really wanted to do something with ragdolls the team had many members who loved games like stick fight, gang beasts and human fall flat and we really wanted to look into making our own. Unbeknownst to me at the time, this was going to be where I would spend a large amount of time of the early project working this to a point it was playable.
After doing some background searching, I came across two incredibly helpful resources: the YouTube channels "Happy Chuck Programming" and "Sergio Abreu García." Both channels provided detailed tutorials on implementing active ragdolls, with Sergio’s video even offering a GitHub project to explore. Despite how straightforward the process seemed in the videos, I quickly realized this would be no walk in the park. but with optimistic hope I got started working on my own.
Unity has a simple and easy to use ragdoll system that throughout the implementation we used greatly making use of the configurable joints throughout.
Abode Maximo also worked formidably to set all this up. Maximo formats their models and can alter yours to easily fit into the ragdolls layout and sorting your hips and accompanying limbs this in the future also worked well to setup us for setting up animations with “humanoid” layouts.
Most active ragdoll setups require introducing a buoyancy system to keep your player from collapsing to the ground, so I needed to handle the movement as if the player was floating above the ground as the legs despite having contact with the ground didn't apply enough friction to slow or stop the player. The simplest solution would have been to simply increase the friction on both feet to increase the resistance. This felt like it was going to cause issues later on and I thought that the best solution was instead to handle the friction of the player in the movement as it would allow better control down the line and could be easily removed should I be needed too. This ended up making the movement snappy and feeling like it was in a good point.
After the player was moving the next issues raised it head. Getting the player to stay upright. After my initial look into systems like this I knew that the best way to handle staying upright was to pull up from the head and down on the hips acting as if pulling a rubber band taught. This was something I amended later in the project after I had separated myself from the issue and got some fresh eyes. But I had overlooked this when setting up the movement and I had to come up with a new solution to sorting this issue. It complicated things a lot but came in useful later. To do this I looked into PID controllers – these are systems that in their simplest explanation are correcting systems that control system flows to allow them to near a closer and closer to a target value correcting based of error margins. The plan was to use a simple version of this system that could then control the force of Unity's built in configurable joint system to increase the power of the spine and hips to move them to their upright position with more strength as the player fell further.
The player after many iterations was looking like it was in a good place the player had the floppy look, we were looking for and was moving as it was when the player had no rigidity and despite a week of tweaking a polishing on top of this. It was working consistently. So, I moved onto sorting player balance. This included things like checking if there was ground below the player, if they were falling over and if they were hit. This script was something that as I developed more complicated systems like powerful hits could be easily expanded to facilitate more checking statements and control movement and is something I find I use in all my future projects in one form or another. It's simple and only really changes Booleans and with simple properties can be referenced in movement classes.
What did I learn from this?
Looking back on this project, the real takeaways weren’t just about the technical improvements I made (though I did pick up some handy real-world math, like calculating friction and understanding the difference between static and dynamic friction and Learning about PID systems). Those things were fascinating! But, my eagerness to dive in headfirst taught me the biggest lessons.
At the start, I was so excited to get going that I overlooked a bunch of issues. Instead of tackling them right away, I let them pile up, which only made things worse. Unfortunately, by that point, a few systems had gone too far to save, and they caused problems later on.
The turning point came after Danny B our Lead artist developed the new player model. It gave me the breathing room I needed to take a step back, reflect, and rethink my approach. With that clarity, I could address my mistakes head-on and make some significant changes in a new direction.
The final result isn’t perfect, but it’s something I’m genuinely proud of. It has a certain charm, even with its flaws. Plus, it handles three large systems (Ragdolling, Movement and Animation Mirroring / Joint Control) without any bugs, and it’s brought a charm to our game that is at its core.
Further Reading:
Proportional–Integral–Derivative Controller (PID) (2023). [Online Article]. Available at: https://en.wikipedia.org/wiki/Proportional%E2%80%93integral%E2%80%93derivative_controller [Accessed 6 December 2024].
References:
Happy Chuck Programming (2023). "Active Ragdolls – Programming Tutorial." [Online Video]. Available at: https://www.youtube.com/watch?v=nmN1TyEd7lE [Accessed 6 December 2024].
Sergio Abreu García (2023). "Active Ragdolls and GitHub Project." [Online Video]. Available at: https://www.youtube.com/watch?v=HF-cp6yW3Iw&t=3s [Accessed 6 December 2024].
Gang Beasts Official Website (2023). Gang Beasts Game Website. [Online]. Available at: https://gangbeasts.game/ [Accessed 6 December 2024].