Monday, January 24, 2022

Create story and world character prefab

Creating the prefabs for the characters in our game is a bit of work. Custom scripts with a lot of options and a few more edits make it quite a task. As we were updating our characters (which sometimes required us to rebuild the entire character prefab because we unpacked the character FBX) and the rapid addition of new characters required us to automate the process.

The script goes through the hierarchy of the selected FBX and edits a couple of transforms based on naming conventions adding components. We use sockets in our game to add props to characters (with a *_socket suffix. These include hands, body, head, world) so these are stored in a list. Our characters can have multiple outfits (with *_outfit suffix) so we also create a list of those.

After we have stored all the transforms we need, the script continues to add the main character script and populates it with the found sockets and outfits. Since we have a different prefab for a character in the story and in the world, a world variant is also created. This includes taking some meshes and creating prefabs and assigning and creating different materials.

After it's done the character is added or updated to a custom resource script.

No comments:

Post a Comment