3D Avatars

One of the largest projects I’ve worked on during my time at Sumdog was on their new 3D Avatars. Previously, Sumdog had some avatars the user could create to represent themselves in games, however they looked a little dated (they were effectively flat/cardboard cutout avatars in a 3D environment). An external company helped make the avatar models and accessories, and our team worked to integrate these assets into the Unity app, allowing the user to create and customise their avatars and see them in the vast majority of games on the platform (and eventually also in the friends area, house, and garden).

Avatar Visualiser

One of my main contributions to this project was a script called the AvatarVisualiser. This script takes an AvatarModel (a data representation of the user’s avatar, deserialised from a json string) and “visualises” it by setting up a visible avatar displaying the various clothing options and features selected by the user. This script has become one of the foundations of the avatar project, used in every single scene the avatar’s visible in.

As part of letting the user apply different clothes and facial features, part of what the visualiser does is to ensure the clothes applied work well with each other. For instance, if a user’s avatar has an afro and they try to apply a hat, the visualiser can use the information on the assets to know to apply a “hat-friendly hairstyle variant”, which creates the illusion of the afro being squished under the hat.

Early on in the project, one of the issues we ran into was with items of clothing clipping with the avatar model, This meant parts of the avatar’s skin could appear through the clothes they were wearing. I was able to address some of this by adjusting the weight-painting on the clothing models themselves in Blender, but for some of our animations (e.g. running) this still wasn’t sufficient, particularly with dresses.

To address this, I worked on two solutions which we apply based on the severity of the clipping:

  • Blend Shapes (Unity)/Shape Keys (Blender).
    • I edited the avatar models we received and set up “shape keys” as they’re called in Blender. These then gave us options on the SkinnedMeshRenderer component in Unity to selectively shrink parts of the model. We were then able to set up effectively blend shape profiles for asset types, so for instance long dresses could shrink the avatar’s legs significantly all the way down to the ankles, whereas shorts could shrink the upper part of the legs and pelvis but not anything below that.
    • This ended up being our main approach for addressing clipping between the avatar and the clothes they wear.
  • Hiding sections of the avatar model at runtime.
    • There were a handful of occasions where, even with the maximum amount of thinning applied, the avatars body slightly clipped with the clothes they were wearing.
    • As a backup option, I exposed several materials on the avatar model to give us greater control at runtime over the visibility of specific areas. For instance, one material in the materials array would control the feet while another would control the ankles and so on. We could then assign a fully transparent material to the parts of the body we don’t want/need to render at all.
    • For the various item assets (i.e. ScriptableObject instances) in the project, we now have an optional slider that can control, for instance, how much of an avatar’s legs to render.

The new avatar was very well received by kids and teachers alike, with some people even getting in touch to let us know how much some of the additions we’d made had meant to them and some of their kids (e.g. the hearing aids option meant a lot to a school which specialised in helping students with auditory impairments, as did our implementation of the wheelchair option to another school).

Our avatar setup has been used millions of times by students and is definitely one of our proudest achievements and joint-efforts as a squad.