Installation
Import the .unitypackage in the Unity project;
Go to root
EntityPrototype
Game Object and add the scriptAnimator Playables
:
- Add an empty Unity Animator component into the same object or in a child
object:
- In a folder of your preference, create a new
AnimatorGraph
asset:
- Select it and, in the
Controller
field, make a reference to the Unity
animator controller that should be imported:
- Click on the
Import Mecanim Controller
button and the states, transitions, parameters, etc, will be baked into the asset:
- In the Entity Prototype, add the
AnimatorComponent
and, in theAnimator Graph
field, reference the asset of preference:
- In the
SystemConfig
asset, add the Animator systems:
- Create a new Game Object in the game scene and add the
AnimatorViewUpdater
component 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
CustomAnimator
replace withAnimatorComponent
. - Remove
Custom.Animator.AnimatorUpdater
fromFrame.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
Controller
and click onImport Mecanim Controller
again;