Unity 5 sending animation triggers
Options
Hey guys,
To make sure players receive the correct animations, I wrote a scripts which sends the triggers from the animator. This is a part of it
This worked fine in Unity 4.6, but ever since I upgraded to Unity 5 it doesn't update the animations anymore. The actualSpeed is being updated however, so the script is being called.
Have any of you guys experienced problems with this so far? Is this a problem on Unity's end? Photon's end? My end?
To make sure players receive the correct animations, I wrote a scripts which sends the triggers from the animator. This is a part of it
// Send the animation values stream.SendNext(characterController._animator.GetFloat("actualSpeed")); stream.SendNext(characterController._animator.GetBool("setJUMP")); stream.SendNext(characterController._animator.GetBool("setDUCK")); ... // Update the animation values characterController._animator.SetFloat("actualSpeed", (float)stream.ReceiveNext()); characterController._animator.SetBool("setJUMP", (bool)stream.ReceiveNext()); characterController._animator.SetBool("setDUCK", (bool)stream.ReceiveNext());
This worked fine in Unity 4.6, but ever since I upgraded to Unity 5 it doesn't update the animations anymore. The actualSpeed is being updated however, so the script is being called.
Have any of you guys experienced problems with this so far? Is this a problem on Unity's end? Photon's end? My end?
0
Comments
-
Nope, mine worked fine. Chances are the problem is your actual animator got messed up, because the animator actually changed quite a bit. Make sure you animator is properly set up.0
-
Hmm odd. I just made a new Animator Controller, made sure everything is exactly alike but the problem still occurs. Could it have anything to do with my sendrate? As far as I know this hasn't changed however.0
-
Not sure if you want to make this change or not, but on my project I put in RPC calls for when animation triggers/bools change rather than streaming them, since the animations only change at specific times.
I updated to Unity 5 as well though, and had no issues with the animations, they all still work.
Just as a side possibility, did you set up your setJUMP and setDUCK as triggers or bools in the animation editor? They have separate calls and you mentioned triggers in your post, but you are using Get and Set Bools, so it could have to do with that if they are different as well.
Good luck!0 -
Sorry to double post, but if you have notifications setup I wanted to make sure you saw this.
While the animations didn't break in my photon using project, I just updated another project today (that doesn't use photon) and several of the character animation links were broken. So like FarmerJoe said I would just recommend reviewing your connections between animations, the links, and the conditions to make sure none of those got messed up in the upgrade.0 -
Apologies for the late reply, I started working on something else and didn't think about the animations anymore.
The problem still persists however. I changed my code according to your tip, so now every time I want to set an animation I send out an RPC with the hash number. Objects which are not owned by the player seem to be only updating their animations randomly however.
Here's my codeif (!offlineTesting) photonView.RPC("AnimationSetTrigger", PhotonTargets.All, hash_duck); else animator.SetTrigger(hash_duck); .. [RPC] public void AnimationSetTrigger(int animationHash) { // Set an animation according to the animationHash animator.SetTrigger(animationHash); }
offlineTesting is an editor bool for when the designer wants to playtest offline. Do you see any problems with this code? I'm afraid it might have to do with the send rate..0