About

I'm developing my first game, Age of Goblins. I develop this part time, and work at a "real" (read: paying) job full time. Age of Goblins is a three dimensional goblin empire building game. Inspired by Dwarf Fortress and Minecraft. Age of Goblins gives a player control over a small band of goblins in a cube-based sandbox world. The player can instruct the goblins to add or remove different types of cubes, build various structures, make elaborate traps, and craft a multitude of items.

Thursday, November 1, 2012

Implementing animation was like pulling my own teeth

These are the latest things to be checked off my to-do list:

  • Model Animation - This one took a while and had me pulling my hair out. Most of this went quickly and easily. Turning each bone's translation, rotation and scale into a transform matrix for the bone's vertices took a while. I just kept running into problems. I'd just look at the mangled mess of triangles that was a goblin just a moment ago before I applied the animation. Was my order of operations wrong? It's so close now, but the rotations are backwards. It's nearly working now but the rotations are around where it was before it translated. This is all wrong, redo. Redo, redo, redo. Finally, a clean working implementation. In the end it was just a collection of small issues that had to be solved in the correct order. But that's no matter now, it's working. Now that it's out of the way, it opens up some other tasks on the to-do list:
    • Creating animations: Yes, I need to get all artsy and make animations for my models.
    • Animation system: Creating a system that decides which animation to apply and when. I have the framework for this already in place from implementing the model animation, I just need to flesh it out.
  • Tag system - With all the entities in game being defined by script, tags give me a way of, well, tagging entities to have certain actions performed with them. For example, I can add the `Storage` tag to entities that I want the goblins to look to when they're looking for somewhere to store their goods. Or I can add the `Material` tag to any entity I want to be considered for a crafting material. These tags get processed by the world when they're created. So if an entity has the `Storage` tag, its entity ID is added to the material manager as a receptacle (more on that in a bit). And entities tagged with `Material` get added to the material manager as a loose material. Overall these tags are a way of categorizing entities outside of the Entity/Component system. It's a better way for the world to know more about them without the need to add a component that contains this information. I don't particularly want to add components unless they are going to be active in a system.
  • Material manager - The material manager is just what it sounds like. When goblins want to store a material, the material manager knows where all their storage zones are and which zones are accepting what materials. It also serves the other side of the coin. When goblins are looking for materials to build a structure or craft a thing-a-ma-jig, they can query the material manager to find the nearest materials that meet their bill. The material manager is really just a interface to another recent addition to the game, the spatial manager. The spatial manger is a generic spatial management system that implements spatial partitioning algorithms to find what stuff is closest to other stuff. Of course this is all invisible to the player, as they'll just see goblins dropping things off and picking them up at the nearest place.
  • Zones - Zones are used to define anything from meeting places to where to harvest flora to where to dump the rubbish. I've implemented pathfinding related to zones as well so goblins can either find a path into a zone, or out of one. The path finding into a zone is useful for returning to the "home" zone and the path finding out of a zone is useful for clearing the area for a structure or cube placement.
  • Storage Bins - Needing something to test out the changes implemented above, I created a basic storage bin. If a bin is available, and goblins don't have something better to do, goblins will transport materials to the storage bin for easy access. There's a neat incentive for using storage bins that I'll reveal when I'm further along with implementing it.
  • Various job improvements - Goblins now have a pool of idle tasks to pick up if they feel like it. They can postpone their current task if it's low enough priority compared to a new task. Adding cubes will now use the material manager to select the optimal materials for building. A building task can not be queued up if the materials are not available.
  • Defensive auto cannons - Yeah, those are kind of in there. I added the ability to add tags to bone names in Blender for use in animation. For example the defensive auto cannons have a tag for `Look_X_Axis` on one of their bones. That bone is then used when creating a "look at" matrix for targeting. This is just one more feature for future player customization. 

No comments:

Post a Comment