The flying animal fiasco

Thought I’d do a short post about an amusing bug. It’s actually been happening occasionally for a while, but after a recent update it became pretty much 100% of the time: certain monsters, like great cats, would charge at you, ready to attack, then leap forward — and instead of landing, they would simply fly right over your head, and keep on going up into space.

Wait, panther, we were fighting! You can't just fly away!

Wait, panther, we were fighting! You can’t just fly away!

This took an entire day to track down, but here’s what happened. First, the panther’s physical body is really just a sphere-ish kinda shape:

The green circle is the cat's physics -- where it can collide with things.

The green circle is the cat’s physics — where it can collide with things.

When it comes time to move the monster around, the graphic of the cat is unimportant. The invisible sphere is what moves around, and the graphics are just drawn on top so you can tell where the heck it is.

The problem came on the server. The server doesn’t bother with the cat graphics at all — why should it? But without any graphical shape, it’s extremely hard to debug. So when I was first debugging the server, I made it draw a little capsule overtop each creature.

This is that same cat, as seen by the server's debug-viewer

This is that same cat, as seen by the server’s debug-viewer

So what went wrong? Somewhere along the way, I must have mis-clicked in Unity, and I gave that little white capsule physics — it became tangible. This meant the cat had two physical forms: the sphere and the capsule. They were both “the cat.”

When the cat wanted to pounce on someone, it moved the green sphere toward them. But then it noticed it was “bumping into” the capsule representation of itself. It decided “oh, I’m standing on something,” not realizing that it was standing on itself! So then it tried to climb over the capsule, which is impossible since they were connected. As soon as the sphere moved, the capsule moved with it.

So the poor cat just kept climbing up its own capsule, often for miles, until it would twist and turn in a way that didn’t register as being “on top of” the capsule for a moment. At that point, it would plummet out of the sky. This is why some players reported seeing monsters hurtling toward them like meteorites.

As soon as I made the capsule intangible, everything was fine again. It just took hours to find the problem.

Well, on the bright side, at least some cats and pigs got to see outer space.

This entry was posted in Project Gorgon. Bookmark the permalink.

8 Responses to The flying animal fiasco

  1. David Lennon says:

    It’s like you’ve reinvented the Turbine Engine, warts and all. ;)

  2. David says:

    Hmm… Actually this could be inspiration. Maybe something like Meteorite Golems? Basically rock golems that fall out of the sky when they respawn?

  3. kalamona says:

    Unity automatically adds colliders to all primitives.

  4. kalamona says:

    When created, I mean. Once you removed the collider, it stays that way of course :) but if you make a new sphere, it will have a sphere collider in it.

  5. Ken says:

    Hehe, that looks like a mistake many programmers could make. I did learn that dungeon ceilings do not seem to have collision detection for monsters. I made at least one bear go into orbit down there and the weird thing is.. he came back down mad as ever.

  6. Ken says:

    Oh Eric, I noticed yesterday that two companies are trying to track users of this page. Google Analytics, and WordPress Stats appear to have done some kind of header injection, though I’m no expert on that, but I did confirm it by looking at the html.

  7. Rauxis says:

    Hilarious! But now the question would be … why not put that to use? Like an arcane spellcasting mishap that accelerates your target into a parabolic trajectory. Could be funny both for the original caster and the unsuspecting target :P

    Rauxis, chosen of CAT

  8. Eric says:

    @kalamona – hey, how’ve you been? You’re probably right that I just forgot to take it off the capsule in the first place. It just didn’t happen to cause any problems until one day I made the other collider a little bigger, and suddenly they interfered.

    @Rauxis and @Ken – yep, thinking about how to use it. I actually originally had a variety of Weather Witching planned, called “Meteorology”. It let you summon meteors from the heavens. But I decided that pun was too terrible. I might still let you summon meteors though…