"Sometimes you try to fix bugs and then your bug fix creates even more serious bugs…
So there was this weird issue with corpses where sometimes they’d rotate around 90 degrees on the y-axis for no reason. When enemy soldiers die, I disable their animator and navigation agent, so there’s nothing that should be modifying their rotation.
The first thing I thought of was that the ragdoll effect was causing problems, so I wrote a coroutine that puts constraints on the rigid body joints and makes them kinematic (probably not necessary to do both) 3 seconds after the body touches the ground.
And this created even worse problems. Some corpses (maybe 1 in 5) would twitch around like in the GIF above, and others (approx 1 in 10) would fold in on themselves like in the GIF below.
This was completely unacceptable. The original bug was much less distracting and preferable to these problems… And since these issues were happening seemingly randomly, I had no idea what to do. After spending hours playing with different values in the physics settings, rigid body settings, and character joint component settings, I was ready to give up.
And then I remembered… I was setting the neck joint angle manually in the enemies to make them look forward (overriding the animation). I thought maybe that was the cause of the twitching at least. So I deleted the coroutine that locks the corpses and made the neck joint function only run while the enemy is alive. And this fixed everything, even the original bug of enemy corpses turning randomly while dead.
Lesson learned - don’t modify transforms directly when ragdoll is active. I thought I wasn’t doing that, but I was. Glad it all got resolved though. It’s like a curse has been lifted. No more possessed corpses in this game. …Oh wait, isn’t this game about possessing NPCs? Maybe these corpses SHOULD be doing weird things. Hmm…" (c) Sean, the Wonhon: A Vengeful Spirit developer.
Ragdoll bugs (July 27, 2019)
Sometimes you try to fix bugs and then your bug fix creates even more serious bugs…
Posted by Super!com on