AnimationSynchronizable Class
Synchronizable Animator component.
In most cases, you should avoid synchronizing the animations as they are usually not deterministic and can be performed from actions directly.
For example, instead of playing walk animation, you should consider animating based on the velocity of the character locally.
AnimationSynchronizable is used together with the Unity Animator.
Adding a AnimationSynchronizable component to a GameObject will automatically add the Animator component.
To sync using the AnimationSynchronizable component, you need to call the method from the AnimationSynchronizable component.
using UnityEngine;
[RequireComponent(typeof(Alteruna.AnimationSynchronizable))]
public class MyAnimatedObj : MonoBehaviour
{
private Alteruna.AnimationSynchronizable _aniSync;
// We can optimize by precalculating the hash of the animation state.
private int JumpId = Animator.StringToHash("Jump");
private void Start()
{
_aniSync = GetComponent<Alteruna.AnimationSynchronizable>();
// We can get the Unity Animator from the AnimationSynchronizable component.
if (_aniSync.Animator.isHuman) print("Humanoid");
}
private void Update()
{
// Play animation
if (Input.GetKeyDown(KeyCode.Space))
{
// play for all clients
_aniSync.Play(JumpId);
}
}
}
AnimatorUpdate | |
Play(Int32) | |
Play(String) | |
Play(Int32, Int32) | |
Play(String, Int32) | |
Play(Int32, Int32, Single) | |
Play(String, Int32, Single) | |
Rebind | |
Reset | |
ResetTrigger(Int32) | |
ResetTrigger(String) | |
SetBool(Int32, Boolean) | |
SetBool(String, Boolean) | |
SetFloat(Int32, Single) | |
SetFloat(String, Single) | |
SetInteger(Int32, Int32) | |
SetInteger(String, Int32) | |
SetLookAtPosition | |
SetTarget | |
SetTrigger(Int32) | |
SetTrigger(String) | |
Start | |
StartPlayback | |
StopPlayback | |