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 KingKongFu · Dec 27, 2012 at 03:11 PM · animationrpcnetworkview

RPC calls and animation problems

Hello, I have been working on this a bit and I am stuck. To me this looks right but I maybe using the PRC function of the network view wrong.

What I want to do is get the animation to player for all players in my network game but it only plays the waiting animation, not the walking animation as of now and it gave me this error.

RPC call failed because the function 'Walk' does not exist in the any script attached to'Jumper(Clone)' UnityEngine.NetworkView:RPC(String, RPCMode, Object[]) TetControl:Update() (at Assets/PlayerScripts/TetControl.js:106)

This script is attached to a prefab that has the model as a child, I basically created a empty gameObject then dragged the model with the animation into the gameObject.

Thanks for any help with this

 //variable for model manpulation
 var model : GameObject;
 
 //basic set of animions for the game
 enum AniState { Wait,
                 Walk,
                 Deployed, 
                 Falling, 
                 TurnLeft,
                 TurnRight}
                 
 var currentAni : AniState;
 
 
 function Start ()
 {
     //get the model data for animation
     model = GameObject.Find("Jumper with walking");
     
     //defult state
     currentAni = AniState.Wait;
 }
 
 function Awake()
 {
     model.animation.wrapMode = WrapMode.Loop;
     //defult start this animation
     model.animation.CrossFade("Wait");
       
 }
 @RPC
 function Update () {
 
 if(networkView.isMine)
 {
     
     if(Input.GetKey(KeyCode.M))
     {
         this.transform.position += this.transform.forward * speed;
         currentAni = AniState.Walk;
             
     }
     else
     {
         currentAni = AniState.Wait;
         //hide the chute
         
     }
     
     if(Input.GetAxisRaw("Triggers") == -1)
         {
             this.transform.Rotate(Vector3.up * Time.deltaTime * turnspeed);
         
             
         }
     if(Input.GetAxisRaw("Triggers") == 1)
         {
             this.transform.Rotate(-Vector3.up * Time.deltaTime * turnspeed);
     
         }
         
     
     //chose animation
     switch(currentAni)
     {
         case currentAni.Wait:
             //play waiting animation
             model.animation.CrossFade("Wait");
             //send the animation to other players
             //networkView.RPC("Wait",RPCMode.All);
             networkView.RPC("Wait",RPCMode.All);
             break;
         case currentAni.Walk:
             model.animation.CrossFade("Walk");
             networkView.RPC("Walk",RPCMode.All);
             break;
         case currentAni.Deployed:
             model.animation.CrossFade("DeployFalling");
             networkView.RPC("DeployFalling",RPCMode.All);
             break;
         case currentAni.Falling:
             model.animation.CrossFade("Fall");
             networkView.RPC("Fall",RPCMode.All);
         default:
             model.animation.CrossFade("Wait");
             networkView.RPC("Wait",RPCMode.All);
             //make him stand still
             break;
             
             
     }//end of switch
 }
 }
 
Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
3

Answer by whydoidoit · Dec 28, 2012 at 08:32 AM

So RPC calls a function - you haven't written the functions called Wait, Walk, Fall etc - I think what you are trying to do is this:

  @RPC
  function PlayAnimation(animationName : string)
  {
      model.animation.CrossFade(animationName);
  }
 ...
 switch(currentAni)
 {
    case currentAni.Wait:
      //play waiting animation
      //send the animation to other players
      networkView.RPC("PlayAnimation",RPCMode.All, "Wait");
      break;
    case currentAni.Walk:
      networkView.RPC("PlayAnimation",RPCMode.All, "Walk");
      break;
    case currentAni.Deployed:
      networkView.RPC("PlayAnimation",RPCMode.All, "DeployFalling");
     break;
  ...
Comment
Add comment · Show 4 · 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 KingKongFu · Dec 29, 2012 at 02:15 PM 0
Share

Thank you for helping me.

it still does not play the animation. he still slides I have a network view on both the prefab and the model in the prefab, but I think that only looks at translation and location not animation. Is there something That I have forgotten to add?

avatar image whydoidoit · Dec 29, 2012 at 02:18 PM 0
Share

You need to just indent code by 4 spaces or 1 tab and paste it into the comments box - I can't read that. It looks like you are still passing a parameter "Wait" to your function that doesn't need a parameter...

avatar image KingKongFu · Dec 29, 2012 at 11:55 PM 0
Share
     switch(currentAni)
     {
     case currentAni.Wait:
         //play waiting animation
         model.animation.CrossFade("Wait");
         //send the animation to other players
         //networkView.RPC("Wait",RPC$$anonymous$$ode.All);
         networkView.RPC("PlayAnimation",RPC$$anonymous$$ode.All, "Wait");
         break;
     .......
     @RPC
      function PlayAnimation(animationName : String)
      {

              model.animation.CrossFade(animationName);

      }
avatar image KingKongFu · Dec 29, 2012 at 11:56 PM 0
Share

This is what I have so far that have been working with but still no animation plays I have even made a new function for every animation that the model has but still not use.

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

9 People are following this question.

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

Related Questions

Networked Animations Play Partially Or Not At All 0 Answers

How To Get Current Animation Name 3 Answers

Parenting and RPC functions 1 Answer

networkView.RPC() inside a ScriptableObject 1 Answer

How can I send a mouse click to a server using an RPC? 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