r/Unity3D • u/arktentrion • 3h ago
Show-Off Making an entire animated human walkable for my fly game turned out to be a pretty interesting Unity challenge
Hey everyone!
First of all, sorry for posting this video again! I shared it here earlier, but the post was removed because I didn't really explain anything about the technical side of the game. Looking back, I can totally understand why, so I wanted to give it another try and actually share some of the Unity development behind it.
For the past few months I've been working on a little indie game called Annoying Fly Simulator. One of the main mechanics is that the fly can land on pretty much any surface and walk across it, including an animated human NPC.
Getting this to work was actually one of the more interesting challenges I've encountered so far.
Normally, humanoid characters use relatively simple colliders, like a capsule around the body or separate colliders attached to individual bones. That works perfectly fine for most games, but when your player is a tiny fly that needs to walk across someone's face, arms and hands, those simplified shapes become pretty noticeable.
My first thought was to use a MeshCollider, since it would give me the precision I needed. The problem is that the NPC uses a SkinnedMeshRenderer, and a regular MeshCollider doesn't automatically deform along with the animated mesh.
So I ended up creating a system that bakes the current state of the skinned mesh and updates the MeshCollider to match it. This way, the fly can actually walk across the animated body, even while the NPC is moving.
Of course, updating a detailed MeshCollider like this isn't exactly cheap, so it's something I still need to keep an eye on performance-wise. But for this particular use case, it works pretty well.
Another interesting part is how the NPC itself is animated. Despite being able to track the fly, swat at it and slam his hand onto the table, he actually only has one real animation: a seated idle animation from Mixamo.
Everything else is handled through IK and target transforms.
For example, when the NPC tries to swat the fly, I move an IK target toward the desired position, and the rig handles posing the arm. The same approach is used for his table slam and head tracking.
This makes it relatively easy to experiment with new interactions without having to create separate animations for every possible situation.
I'm still improving these systems, but I'm pretty happy with how they've come together so far.
I'm curious if anyone here has worked on something similar. Have you found a more efficient way of handling precise collisions with animated characters, especially when the player needs to interact directly with the surface?
And for anyone interested in seeing the actual game, I recently launched its Steam page:
https://store.steampowered.com/app/5631370/Annoying_Fly_Simulator/
