Installation
Import the .unitypackage in the Unity project;
Go to root
EntityPrototypeGame Object and add the scriptAnimatorMecanim:
- Add an empty Unity Animator component into the same object or in a child
object:
- In a folder of your preference, create a new
AnimatorGraphasset:
- Select it and, in the
Controllerfield, make a reference to the Unity
animator controller that should be baked:
- Click on the
Bake Animator Graphbutton and the states, transitions, parameters, etc, will be baked into the asset:
- In the Entity Prototype, add the
AnimatorComponentand, in theAnimator Graphfield, reference the asset of preference:
- In the
SystemConfigasset, add the AnimatorSystem, AnimatorBehaviourSystem and AnimatorTriggersSystem systems:
- Create a new Game Object in the game scene and add the
AnimatorViewUpdatercomponent to it:
- This is the initial setup. Using the Animator API on the simulation, such as setting animator parameter values in runtime is already enough to start the deterministic animations.
The basic API is similarly to how it is done on Unity, use Getters and Setters in order to read/write to the Animator:
C#
// Getters
AnimatorComponent.GetBoolean(frame, filter.AnimatorComponent, "Defending");
AnimatorComponent.GetFixedPoint(frame, filter.AnimatorComponent, "Direction");
AnimatorComponent.GetInteger(frame, filter.AnimatorComponent, "State");
// Setters
AnimatorComponent.SetBoolean(frame, filter.AnimatorComponent, "Defending", true);
AnimatorComponent.SetInteger(frame, filter.AnimatorComponent, "Direction", 25);
AnimatorComponent.SetFixedPoint(frame, filter.AnimatorComponent, "Speed", FP._1);
AnimatorComponent.SetTrigger(frame, filter.AnimatorComponent, "Shoot");
Replacing the old Custom Animator
- Make sure you have a backup of the project.
- Delete
QuantumUser/Simulation/QuantumCustomAnimator. - Delete
QuantumUser/View/CustomAnimator. - Delete
Scripts/QuantumCustomAnimator. - Import
QuantumAnimator.unitypackage. - On all scripts that uses
CustomAnimatorreplace withAnimatorComponent. - Remove
Custom.Animator.AnimatorUpdaterfromFrame.User.
Replacing CustomAnimatorGraph
In case the CustomAnimatorGraph assets is not working follow this steps:
- Change the Inspector to Debug mode.
- Select the asset and remove the attached
Controller. - Click on
Import Mecanim Controller. - Reattach the
Controllerand click onImport Mecanim Controlleragain;