Skip to content
Nunchuk/ToasterOven edited this page May 5, 2023 · 17 revisions

Glossary

Creating Emotes

General Flow for Creating Emotes

  1. Rip/Create a humanoid animation in Blender or your modelling program of choice
  2. Import said humanoid animation into unity
  3. Import/create any extra props you will need for said emote (Optional)
  4. Export the Assetbundle with animation and props, if any, into your dll project
  5. Create WWise events and import the bnk file into your dll project (Optional)
  6. In code, add your imported .anim files to CustomEmotesAPI

Rip/Create a humanoid animation in Blender

For ripping animations from games, you're on your own. It largely varies from game to game.

For creating your own animations, Unsaved Trash#0001 has created a boilerplate blender file which contains the default Unity humanoid guy.

For more info, see the full blender flow

Import animation into unity

Once you are satisfied with your animation. Save your blend file (or FBX if you are cringe) somewhere into your Unity project.

For more info, see the full blender flow

Creating extra props

This is a much more open ended step. Depending on the emote you are setting up, you might want some props to spawn around or attached to the character during an emote. At this point, you should create any and all props you need before setting up your Assetbundle.

For a small example, see the example prop page

Exporting to your project

Once you have all the assets you need, create an Assetbundle and import it into your dll project.

For more info, see the AssetBundle tutorial

Using WWise

If your emote is going to contain audio, you will need start and stop events from WWise. If you are unfamiliar with how WWise works, please buckle in and check out the RoR2 modding wiki's page on this topic.

Importing the animations to CustomEmotesAPI

Once you have your Assetbundle (and possible bnk file). All that's left is to import them into the game. If you want, there is an example project which you can download and use to quickly setup your emotes.

For more info on all the ways to setup an animation with CustomEmotesAPI, see page for adding custom animations

Creating Emote Skeletons (AKA: add support for modded characters)

General Flow for Creating Emote Skeletons

  1. Create a copy of the Blend/FBX file you use for the character's body
  2. Using said copy, configure it in unity to be as accurate to humanoid as possible
  3. Create a new prefab with this humanoid body
  4. Give the prefab an animator with root motion turned off
  5. Export the Assetbundle into your dll project
  6. Setup the prefab to be imported upon SurvivorCatalog.Init
  7. Setup icon on the wheel in-game

Create a copy of the character body

In your unity project, find the body blend/fbx file you use for said survivor/enemy. Create a copy of this file and rename it to something like charactername_emoteskeleton (doesn't really matter, just for organization sake)

Configure new body to be humanoid

Once you have your copy, select it and go to the rig tab and select humanoid animation type. Hit apply and once it has auto set the body up, click configure and verify everything looks normal and is in T-Pose.

For more info on this see example humanoid setup

Also, starting from this step forward, if a video would be easier to follow you can always watch it here https://youtu.be/ixJxmpBR4kc?t=130

Creating prefab

Once you are done with this, drag your file into your scene and then back into your files to create a prefab.

Setting up the animator

Once you have your prefab, it should automatically have an Animator. However, if it does not for any reason, you are going to need to add an Animator component yourself and verify it's avatar is your recently created humanoid avatar. Regardless, make sure to uncheck "Apply Root Motion".

Exporting your skeleton

Once you have your emote skeleton prefab, create an Assetbundle and import it into your dll project.

For more info, see the AssetBundle tutorial

Setup the prefab to be imported

Once you have your Assetbundle imported. All that's left is to import your emote skeleton into the game. You will want to hook into SurvivorCatalog.Init and call something along the lines of:

    On.RoR2.SurvivorCatalog.Init += (orig) =>
    {
        orig();
        if (!setup)
        {
            setup = true;
            foreach (var item in SurvivorCatalog.allSurvivorDefs)
            {
                if (item.bodyPrefab.name == "RobPaladinBody")
                {
                    var skele = Assets.Load<GameObject>("fineilldoitmyself/animPaladin.prefab");
                    CustomEmotesAPI.ImportArmature(item.bodyPrefab, skele);
                    skele.GetComponentInChildren<BoneMapper>().scale = 1.5f;
                }
            }
        }
    }

Setup icon on the wheel in-game

This step is completely optional but the emote wheel ingame supports a custom icon in the middle. If you want to modify that it's as simple as

    CreateNameTokenSpritePair("CAPTAIN_BODY_NAME", Assets.Load<Sprite>("@CustomEmotesAPI_customemotespackage:assets/emotewheel/captain.png"));

Obviously, you replace the items here with your name token/sprite. You can find the template I used here (please ignore the jank)