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 thornekey · Mar 11, 2014 at 08:38 AM · animationnetworkingmultiplayerrpc

How to use RPC functions to animate other players

How would i go about using RPCs to make other players animate when theyre walking, jumping, and idle, etc :P

Really curious. If someone could help thatd be great. Any code preferred in C# but not detremental :))

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 softrare · Mar 11, 2014 at 09:31 AM 0
Share

I solved the problem generically in my asset store package: https://www.assetstore.unity3d.com/#/content/13867 . All animations from all actors are being automatically synchronized across the network if you wish so.

avatar image thornekey · Mar 11, 2014 at 09:38 AM 0
Share

nice asset :) although, id like to script it myself :P not use assets :))

avatar image softrare · Mar 11, 2014 at 10:00 AM 1
Share

I understand. The non-generic way would be to do sth like this:

$$anonymous$$ake a function in a script on your character

 [RPC]
 public void netWalk() {
    animation.CrossFade("walking");   
 }

So ins$$anonymous$$d of just saying animation.CrossFade("walking") you would call that function with

 netwokView.RPC("netWalk",RPC$$anonymous$$ode.All);

Then the function should be executed on all clients (and the server). I have not tested the code just now, but that's about how it can be made to work.

1 Reply

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

Answer by whydoidoit · Mar 11, 2014 at 09:46 AM

I wrote an article that has the basis of this principle: http://unitygems.com/weak-associations-leak-free-extension-properties/

Comment
Add comment · Show 6 · 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 thornekey · Mar 11, 2014 at 09:56 AM 0
Share

nice article, ive started reading :)) it looks complicated though ughh

avatar image whydoidoit · Mar 11, 2014 at 09:59 AM 0
Share

It is a bit complicated - but you can download the weak table stuff and use the example which sends animation data over Unity networking.

avatar image thornekey · Mar 11, 2014 at 10:01 AM 0
Share

how could i implement it to this script. I wrote this a few nights ago, knowing nothing about RPCs so i knew it wouldnt work..

     public float stopAnimation = 0.5f;
     
     void Update ()
     {    
         var directionVector = new Vector3 (Input.GetAxis ("Horizontal"), 0, Input.GetAxis ("Vertical"));
         if (networkView.is$$anonymous$$ine) {
         
             if (Input.GetButton ("Jump")) {
                 this.animation.CrossFade ("manP_jump");
             } else {
                 if ((directionVector.x > stopAnimation || directionVector.x < -stopAnimation) ||
                             (directionVector.y > stopAnimation || directionVector.y < -stopAnimation) ||
                 (directionVector.z > stopAnimation || directionVector.z < -stopAnimation)) {
                 
         
                 networkView.RPC("NetworkRun", RPC$$anonymous$$ode.All);
                 
                 } else {
                 networkView.RPC("NetworkIdle", RPC$$anonymous$$ode.All);
                 }
             }    
         }
     }
     
     [RPC]
     public void NetworkRun ()
     {
         animation.CrossFade ("manP_run");
     }
     
     [RPC]
     public void NetworkIdle ()
     {
         animation.CrossFade ("manP_idle");
     }
avatar image thornekey · Mar 11, 2014 at 10:14 AM 0
Share

i have got it to work yet it is leaking the data :/ hmm

avatar image whydoidoit · Mar 11, 2014 at 10:33 AM 0
Share

Ok what it does is takes the animation on one character and sends it across the network. So you don't really send each one.

The idea is that you call SendAnimation regularly using InvokeRepeating or a coroutine (perhaps a a few times a second, and then only if something has changed). It calls the ReceiveAnimations across the network which then plays them all.

Show more comments

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

22 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 avatar image avatar image

Related Questions

Unity networking tutorial? 6 Answers

Animation over network using rpcs 0 Answers

PhotonView over GameObject 2 Answers

Animation triggers on all instances of player. 2 Answers

Multiplayer - Selected character to Network.guid? 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