Adding Spring Bones in UniVRM (Optional)
Adding Spring Bones and Collider Groups Video Tutorial
As noted it is possible to add certain elements to your VRM to improve the overall result such as adding secondary animation automatically. If you are using the VRM in other platforms other aspects such as blend shapes for lip sync, Look at functionality, and blinking are some other examples you can add.
To further develop the VRM we need to import the VRM that we exported in the last tutorial. By exporting and importing the asset we can easily set up all the elements needed for the VRM Avatar.
Depending on the use of the avatar, some of the elements are optional. Mona does not support the LookAt functionality or use blend shapes at the moment, but this may change in the future. That said, other platforms that you may want to use the Avatar on do (such as VRChat etc.) so it is up to you in regards to how far you take the functionality of the Avatar.
As you can see below, there are a lot of scripts added to the avatar in order for it to work as a VRM Avatar. So exporting and importing the asset saves a bit of time. As noted, we won't need some of these for now this is just an example.
Some of the elements added to create the VRM Avatar.
So to get your basic VRM Avatar made so that we can modify it, do the following :
- Use Export to VRM 0.x to export your VRM Asset as per previous tutorial.
- In the same menu, use Import from VRM 0.x to import your premade VRM, and then save the prefab to the desired location in your project. It is recommended to place it in a separate folder, so you can easily track which is your original files and which are the final VRM Avatar files.
- You can then place the new VRM Prefab in your scene.
As noted in a previous doc, Spring Bones add a secondary motion to certain bones in your avatar. This could be used for things like hair, clothes, or anything else you can think of.
- Expand the VRM asset in the Hierarchy so you can see all the children, and select the 'secondary' asset. This asset has the VRM Spring Bones script.
Select the Secondary asset to see the Spring Bones Script
- Depending on how many sets of bones you want to have secondary motion is how many Root Bones we have to add. So if you have a three bone chain, you need to add the root bone, or start bone, in this list. Use the '+' button to add the amount of bones/bone chains you may have. Use the '-' button if you add too many.
Add Spring Bone slots
- Drag/Drop the root bones of your VRM asset to use as secondary motion from the Hierarchy panel. You could use the circle at the right of the parameter as well if you want. Note that the naming of these bones could be a lot better. This would be done in the 3D Creation tool, Blender in this case.
Add Bone group root to Spring bone script
- You can test the effect if you press Play at the top, go to the Scene window (as it will open the 'Game' viewport automatically), and move the parent object.
Test the Spring Bones in Unity
- It is possible to export your VRM again and use it in a space. You can of course play with some of the features of the Spring bone such as Stiffness, Gravity, Gravity Direction, Drag Force, and Centre as needed.
You may want your spring bones to interact with other elements of your character such as clothes not going into the character etc. For that you will need to create Collider Groups.
A Collider group is a type of collider on a bone that the Spring Bones will not pass through. That said each collider group is quite CPU intensive, so it is recommended to keep these as low as possible. One or two would be a good recommendation.
- Select the bone you would like to put a collider on. Add the 'VRM Spring Bone Collider Group' script. Adjust the offset and Radius as needed. Usually this may be a head, spine or pelvis. As noted, having a collider on each body part would be quite intensive and is not recommended. In this Avatar's case, I don't want the books or the scarf to go through the main body, and this would require two lower colliders. One around the stomach and one around the pelvis.
Apply the Collider Group Script
- Once the collider group scripts have been applied, add the Collider Group bones at the bottom of the Spring Bone script.
Add Collider Groups to Spring bone script.
- Once again you can test the Spring Bones with Collider groups by selecting the Avatar, pressing 'Play', and test in the Scene viewport.
Test the Collider Groups
- Sometimes you may find that the Collider Group bone may be too small to affect the spring bones, so refine as needed for the best results.
And that finishes your VRM! You can then export it once again and upload it to be used in Mona.