About
This tutorial is the developer/creator guide to implementing the EZSoftBone Library plugin for your own Unity assets.
Tutorial requirements
- You need a good understanding of Unity.
- You need a ready project to build assetbundles for VAM. You can find a tutorial here.
- You need to have downloaded and installed the unitypackage available with this tutorial in your project
- You need to know how to:
- Create a model in Blender (or any 3D software of your choosing)
- Create a rigged model
- Setup a skinned mesh in Unity
- You need to have read the documention of the original EZSoftBones and how to set it up on an asset
Install the package
- Download the zip file included with the tutorial.
- Be sure to have removed any other versions of EZSoftBone libraries if you have some already installed in your project.
- Extract the zip file and install the unitypackage ( this is not a tutorial about Unity usage, Google can help you figure how to install a Unity Package )
When you have installed the package, your project should now contain three new folders
Testing the package before content creation
We're gonna test the package so that we're sure you're ready to create your own asset.
- Go in the VAMEZSoftBonesLibDemo folder, then the Scenes sub-folder.
- Open the VAMEZBonesLibDemo scene
When the scene is loaded, follow the steps as show in the screenshot below
- Click on play. When play mode is started...
- Select the scene view tab
- Select one of the EZSB example gameobject
- Try to wiggle it around
- It wiggles...
- ... and you see the thing white/redish line...
If this doesn't work, it means either your project is incorrectly configured, or it has failed to compile properly. At the moment I have tested the package with several friends, everytime it worked. If it fails on your end, you will sadly... pretty much have to figure out yourself why it does not compile.
Making a custom unity asset compatible with the EZSB library
First, you need to import a model in your Unity project and make it a prefab.
You can look at the most common and recurring type of model you'd use by checking EZSoftBonesExample in the folder VAMEZSoftBonesLibDemo/Prefabs
To summarize the requirements of the prefab :
- It needs to be rigged (this means it needs to have a Skinned Mesh renderer in Unity)
- A set of bones
- Optional: can have an animator
Adding components
Select your gameobject or the child which is going to have the EZSoftBone components.
On the EZSoftBonesExample prefab example, you'll see that the first child named ezbones-demo is the one containing the components.
When you have chosen which element of the prefab is gonna have the EZSoftBone components add the following ones :
- EZSB Controller
- EZ Soft Bone
- VAMEZSoftBonesLib/Runtime/EZSBController.cs
- VAMEZSoftBonesLib/Runtime/EZSoftBone.cs
From there:
- The EZSB Controller component does not need any settings. It's the component allowing VAM to "communicate with the asset".
- The EZ Soft Bone componentneeds you to configure it properly
- As mentionned above, you need to understand how to use the EZSB library ( plenty of resources are available on the usual plateforms )
Testing and publishing the prefab/asset
When you have added your components, save your prefab.
To test it, and ensure the EZSB library works, just like when you tested the unitypackage at the beginning of the tutorial. Start play in editor and try to wiggle it around. If it reacts, it means you have successfully configured the library. If you want to confirm that the VAM EZSB Controller works... when you hit play, you should see the object you added it on be renamed with the suffix "_EZSBC".
If none if these two happen :
- Check your EZ Soft Bone configuration for any mistake
- Check you did not forget to add the EZSB Controller
Non-rigged assets and nested components
The EZSoftBonesExample2 prefab example shows two things:
- You can create nested EZSB children (you need to add both components as explained above on each child)
- You can create physics enabled CUA without using a rig.
Validating the asset in VAM for var packaging
Once you have built the assetbundle, copy it in your VAM folder. Then follow these steps:
- Create an empty scene (add some lights... duh!)
- Add a first Custom Unity Asset
- Add the EZSB Library on this first CUA
- Add a second Custom Unity Asset
- Load the asset you just made in Unity on this CUA
- Load the script EZSoftbones Controller contained in the EZSB Library plugin
At the top, in the EZSB Element dropdown, you should have the name of the prefab or the child your chose when you added the EZSoftBone components.
If you're getting a message "this asset is not compatible with...", it can mean:
- You have not loaded the EZSB Library as explained above
- You haven't added the EZSB Controller component in Unity
The default setup of the plugin will probably constrain a bit more than what you have in Unity. This is why the plugin exists, you can then configure it so that it feels how you want inside of the game. After tweaking the settings and getting the behavior you expect... it means your asset is ready. You can share it on the hub.
Proper var packaging
To prevent players and users of your EZSoftBone power asset to be frustrated when they download it. I would recommend when your asset is final, to create a CUA preset which will have :
- The proper asset selected in the assetbundle
- The script already added on top of the CUA ( the EZSoftBone Controller contained in the library plugin )
I would recommend also that you explain they need to have the library loaded or "copy/paste" the How to use section of the EZSoftBone Library in your release documentation.
You could also make a demo scene with the full setup ready to use.
A word on the EZSoftBone Component/library
Original library
The library you get with the UnityPackage of this tutorial is what you get on github. So there is no difference with the original. It means you can:
- Use physics materials
- Configure your curves
- Define nested structures ( the VAM plugin has a dropdown to handle nested structures! )
- Experiment with the whole library
- ...
Animation compatible
The version I used is compatible with an Animation Controller... as you can test with the Fairy Wings.
This means you can have both animation running AND physics applied on your CUA/rig.
I tested some fork people did... and I can't remember who in the community made a fork that was technically compatible with VAM's physics rate/implementation... but they were all failing at allowing both animation and physics.
Discrepancies
As mentionned above, VAM's physics rate/implementation is a bit different than Unity's default. Which makes the EZSoftBone library behave a bit differently at runtime. But this is were the plugin becomes handy. You can configure your component in Unity, then adjust the setup in VAM.
For all I know, I've tested hairs, tails, wings, jewelry and I ended up getting extremely good result after tweaking with the plugin... so all good for me.
But that information was just so that you are aware of the potential quirks.
Final word
As these technical tutorial are complex, I may have missed some information/details. It might get updated in the future.
If you see anything critical missing, any feedback in the discussion is welcome.
If you struggle with EZSoftBone, the original creator did a full set of tutorials which are quite thorough. It is fully in Chinese, but I succeeded to understand and learn it without understanding jack squat of that language (spoken or written)... So I guess you can too
Some other people did some tutorials, they are not as detailed but should give a starting point.