- Home /
NetworkAnimator: SetBool vs. SetTrigget?
Hello,
For triggers, the network animator knows to access the animator, but for boolean you reference the animator in the script. In c# script the reference for a bool is through: NetworkAnimator.Animator.SetBool
e.g:
NetworkAnimator n_animator; Animator anim; n_animator.anim.SetBool("doSomthing", true)
but for triggers its
e.g:
NetworkAnimator n_animator; Animator anim; n_animator.SetTrigger("doSomthing");
Can someone explain to me the difference between NetworkAnimator calling a bool vs. a trigger?
Answer by unidad2pete · Aug 17, 2017 at 07:10 PM
n_animator is for synchronize animations arround the network, bool can be synchroniced automatically , if you set your bool on your animator component, the newtworkAnimator attached, its changed on all instances if are checked true on the component( Inspector ) or the common code:
for(int i = 0; i < anim.parameterCount; i++)
{
n_animator.SetParameterAutoSend(i, true);
}
But triggers are not sent , and you need call trigger on NetworkAnimator component to say all players you are calling the trigger.
https://docs.unity3d.com/ScriptReference/Networking.NetworkAnimator.html
The NetworkAnimator synchronizes the animation parameters that are checked in the inspector view. It does not automatically sychronize triggers. The function SetTrigger can by used by an object with authority to fire an animation trigger on other clients.
Ok, I accept this answer. I think it helped me understand something. The word "authority" is what makes the difference. Triggers of a need for authority, as if their rank is higher, while booleans are simpler.
Your answer
Follow this Question
Related Questions
UI button doesn't appear - c# 3 Answers
C#: Climb ledge while inside collider 1 Answer
Network Animator set trigger not working 2 Answers
How do I stop my animation from looping while I hold down a key? 1 Answer
Server List 0 Answers