I'm an ex-long time "AAA" game programmer, now solo indie developer making GearBlocks, a game all about creative building, interactive machines, and gears - lots of gears!

Report RSS Character customisation

Posted by on

Over the past few weeks I've been finishing up the player character work I started a while back, along with some code refactoring and other things.

Building a player character

I've now implemented functionality so that a construction built out of body parts can be treated as a player character model. Such a "character construction" differs from a normal construction as follows:-

  • It doesn't get serialized out to saved games, because the player's character construction gets spawned separately (based on what was selected in the character screen, see below).
  • It doesn't collide with other non-character constructions or objects in the world (the player's CharacterController takes care of collisions).
  • It can't be selected, frozen, or destroyed.
  • Body parts in it don't move via physics, instead they are locked to the appropriate animated bone (e.g. head, upper arm, lower leg, etc.)

I added a new character screen accessible from the main menu. This allows the user to select a character construction, which will then be spawned as the player character when entering a game.

To create a custom character, first the user assembles a construction as normal out of body parts, and then they save it via the save construction screen. As shown below, I added a tab to this screen to allow a construction to be saved as a character so that it'll then appear in the character screen and be available for selection.

To switch to the new character, the user then has to exit back to the main menu, go into the character screen and select the one they just saved, before re-entering a game.

In game, the character construction can be seen in the world tool UI just like any other construction. However there are some operations that can't be performed on it as mentioned before: select, freeze, or destroy. This can be seen below, note that the character construction has an icon to identify it as such.

This pretty much completes the player character system although, as always, there are a few loose ends to tie up:-

  • I need to add checks to ensure that the construction is valid to be a character (e.g. has the correct body parts, and they are connected together appropriately).
  • Currently, to change the player character construction the user has to exit back to the main menu, I'd like to implement a way to swap it during game play.
  • The body part meshes need a bit more modelling work.
  • I'd like to add more attachment points to the body parts to allow for more customisation options.
  • I also want to add more body part variants and accessories.

Free flight mode

I've also finished working on a "free flight" mode for the player. This turns off gravity for the player and changes the controls slightly so that the user can fly up and hover in the air, handy for when building large constructions!

Singleton squashing

Finally, I also did another code refactoring pass to eliminate the remaining singleton MonoBehaviours in the game (well nearly). This primarily involved converting them to ScriptableObject assets, and replacing any public method calls with events and handlers. I covered this topic in the ScriptableObjects For Fun and Profit blog post a while back, so I won't go into detail here. Suffice to say I'm done with this refactoring process now, there are only a couple of singleton MonoBehaviours left, which are for my networking abstraction layer (something I also blogged about a while ago), and I think I'm just gonna leave these as they are.

Post a comment

Your comment will be anonymous unless you join the community. Or sign in with your social account: