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 SquidSquad · Dec 12, 2013 at 08:59 PM · animationnetworkingphotonstreamreceive

Photon Stream animation

Hi, I'm trying to play a legacy animation (not using an animator) so that it is visible by the other player. I know how to send it, but how would i receieve it? Thanks in advance for any help.

     public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info) {
         if(stream.isWriting) {
             // This is OUR player. We need to send our actual position to the network.
             stream.SendNext(transform.position);
             stream.SendNext(transform.rotation);
             if(anim.animation.IsPlaying("Swing"))
                 stream.SendNext(anim.animation.Play("Swing"));
         }
         else {
             // This is someone else's player
             realPosition = (Vector3)stream.ReceiveNext();
             realRotation = (Quaternion)stream.ReceiveNext();
             //anim.animation.IsPlaying("Swing") = (bool)stream.ReceiveNext(); <---Doesn't work :( how do i receive it?
         }
     }
Comment
Add comment · Show 5
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 AlucardJay · Dec 12, 2013 at 09:09 PM 0
Share

Why not just send the name of the animation as a string, then on receive check if that animation is playing (if not, crossfade to it, else do nothing)? I'm fairly sure you can only send ints, floats, booleans, strings, Vectors and quaternions through a serialize view (why would you send an animation when the object should already have that animation stored on it?)

avatar image SquidSquad · Dec 12, 2013 at 09:29 PM 0
Share

Thanks, but thats the problem, i can't check to see if another players animation is playing. I'm trying to view the other players animation from the camera this script is stored on.

avatar image FLASHDENMARK · Dec 12, 2013 at 09:48 PM 0
Share

Why not just use RPC calls? Whenever you need remote players to play the swing animation just tell them by using RPC calls.

avatar image SquidSquad · Dec 13, 2013 at 12:27 AM 0
Share

How, if I cant read which player sent it and who needs to see it? syntax would be great.

avatar image Khyrid · Feb 01, 2015 at 05:07 AM 0
Share

Yes, syntax would be great. I keep running into lack of documentation issues with PUN. It seems really simple and efficient though, so I wish I could figure this stuff out.

As for using RPCs, I'm pretty sure that's not what should be used for walking/running animation syncing.

1 Reply

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

Answer by Khyrid · Feb 01, 2015 at 09:57 AM

I had the same issue trying to get PUN to sync legacy animation. This is what I did that worked for me:

    public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info) {
             if(stream.isWriting) {
                 //This is our player, sent pos to network
                 stream.SendNext (transform.position);
                 stream.SendNext (transform.rotation);
                 if(anim.animation.IsPlaying("walk")){stream.SendNext(useThisMove = 1);}else{stream.SendNext(useThisMove = -1);}
             }
             else{ //elses player, recive their pos
                 realPosition = (Vector3)stream.ReceiveNext();
                 realRotation = (Quaternion)stream.ReceiveNext();
                 useThisMove = (int)stream.ReceiveNext(); //This is how I received the data, I just used an int.
             }
         }
 
 
 
 

Then I added this in the update:

     if(useThisMove == 1){anim.animation.Play("walk");}else{if(useThisMove == -1){anim.animation.Play("idle");}} //else won't work.

 

I used this in the update to change the animation of anyone who had the "useThisMove" var changed. I also needed to make sure I had well written animation code or the animation wouldn't stop. I'm sure my code is messy, but it works.

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

19 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

Related Questions

Unity Photon: animation syncing 1 Answer

how to synchronise an animation which is in a second animation layers, over the network with Photon? 0 Answers

How do you sync animations in Photon? 0 Answers

Photon Syncing Animations 2 Answers

Issues on Syncing the animation component on Photon Network 0 Answers


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