Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by moghes · Feb 10, 2014 at 02:46 PM · photonmechanim animation

Sync Mechanim animation with OnPhotonSerializeView in PUN

Hello,

I have touble syncronizing data of Animator component via the callback OnPhotonSerializeView().. I am able to see the transform change and tried the same way with the animator component.

Check the code here:

  void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
     {
         if (stream.isWriting)
         {         
             stream.SendNext(transform.position);            
             stream.SendNext(transform.rotation);
             
             stream.SendNext(this.m_animator);
         }
         else
         {         
             this.correctPlayerPos = (Vector3)stream.ReceiveNext();
             this.correctPlayerRot = (Quaternion)stream.ReceiveNext();
 
             this.m_animator = (Animator)stream.ReceiveNext();
         }
     }

this code is in the script "Network Character" attached to my third person character.

And it gives this error: Exception: cannot serialize(): UnityEngine.Animator

I comment them (leave position and rotation) only, and the error is gone.

Also I thought of this.m_animator.animation = (Animation)stream.ReceiveNext(); but cant do since (`UnityEngine.Component.animation' cannot be assigned to (it is read only)

Any idea of how to syncronize the animations from the animator component?

Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image moghes · Feb 11, 2014 at 10:25 AM 0
Share

I tried an another method, got no errors but animation is not updated on all clients.

 void OnPhotonSerializeView(PhotonStream stream, Photon$$anonymous$$essageInfo info)
         {
             if (stream.isWriting)
             {         
                 stream.SendNext(transform.position);            
                 stream.SendNext(transform.rotation);
                 stream.SendNext(m_animator.GetBool("Idle"));
                 stream.SendNext(m_animator.GetBool("Run"));
             }
             else
             {         
                 this.correctPlayerPos = (Vector3)stream.ReceiveNext();
                 this.correctPlayerRot = (Quaternion)stream.ReceiveNext();
                 this.m_animator.SetBool("Idle" , (bool)stream.ReceiveNext());
                 this.m_animator.SetBool("Run" , (bool)stream.ReceiveNext());
             }
         }
avatar image moghes · Feb 11, 2014 at 02:11 PM 0
Share

Also tried:

 void FixedUpdate()
     {
         m_animator.SetBool("Run" , runBool);
         m_animator.SetBool("Idle" , idleBool);
     }
     
     void OnPhotonSerializeView(PhotonStream stream, Photon$$anonymous$$essageInfo info)
     {
         if (stream.isWriting)
         {         
             stream.SendNext(transform.position);            
             stream.SendNext(transform.rotation);
             stream.SendNext(runBool);
             stream.SendNext(idleBool);
         }
         else
         {         
             this.correctPlayerPos = (Vector3)stream.ReceiveNext();
             this.correctPlayerRot = (Quaternion)stream.ReceiveNext();            
             idleBool = (bool)stream.ReceiveNext();
             runBool = (bool)stream.ReceiveNext();
         }
     }
avatar image aristaios · Jul 28, 2014 at 05:07 PM 0
Share

This may sound stupid; but why is this one variable specifically "m_animator"? Is this just due to personal preference or some coding convention?

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by moghes · Feb 28, 2014 at 10:21 AM

Friends I got help from the photon forum, here's the post link: http://forum.exitgames.com/viewtopic.php?f=17&t=4241

and thanks to Razor.

Here's the link he suggests, which solved my issue: http://www.youtube.com/watch?v=4AZADiKD2sE

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by chin13577 · Jan 29, 2017 at 07:43 PM

another way if you want to sync animation without animator

Photon Play Animation

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

20 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Multiplayer using Photon ?? 1 Answer

Roatate animation starts from 0 2 Answers

Can't get animation preview to display the correct model. 0 Answers

Simple Forward and Backward animation, Char is rotating randomly 0 Answers

Why is my Animation not Retargeting Correctly? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges