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 lizzyCTS · Oct 12, 2011 at 11:06 PM · animationsmultiplayer-networkingrpcanimationstatemultiplayer-tutorial

Issues with using RPC calls for animations

I am currently using a range of tutorials to make a FPS multiplayer game. I cannot figure out why the animations aren't working considering the RPC's are getting called. There are two settings, crouching and standing for the player. The animation for crouching plays as well as standing, but not the animations such as walking. I've put breakpoints at the lines for where the walking/idle animations change and they are hit properly. The debug log is also displayed at the right time as well. All the animations are looped in start, their layers are -9.

Here are the RPC functions:

 @RPC

function SendStance(charStance : String, info : NetworkMessageInfo)

{

  stance = System.Enum.Parse(typeof(charStanceState), charStance);

}

@RPC

function SetDirectionState(directionState : String, info : NetworkMessageInfo)

{

 Debug.Log("directionState is "+directionState);

 dirState = System.Enum.Parse(typeof(charDirState), directionState);

}

Both are getting called in Update, whenever the state changes from the previous state. SetStance is for crouching/standing, whenever you hit the c button this switching the stance. SetDirectionState is for changing the direction at which the player is looking and UpdateAnimation crossfades to the corresponding animation.

 function Update ()

{

 SetStanceState();

 if(prevStance != stance && networkView.isMine)

 {

     networkView.RPC("SendStance", RPCMode.OthersBuffered, stance.ToString());

     prevStance = stance;        

 }

 SetDirectionState();

 if(prevDirState != dirState)

 {

     networkView.RPC("SetDirectionState", RPCMode.OthersBuffered, dirState.ToString());

     prevDirState = dirState;

 }

 UpdateCharacterAnim();



}

If anyone has any suggestions on how to animate characters using RPC please comment or answer. Thank you very much in advance because I'm at my whit's end for this!

Comment
Add comment · Show 1
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 lizzyCTS · Oct 13, 2011 at 01:40 PM 0
Share

Here's a little of the UpdateAnimation function if it helps.

function UpdateCharacterAnim() : void { switch (dirState)

 {

 case charDirState.Idle:        // The player is idle.

     switch (stance)

     {

            case charStanceState.Standing:

         characterAnimator.CrossFade(idleAnimString, .3);
                break;

......... Again, I just don't understand why crouching animations work when walking animations are the same! They're triggered by a button just like crouch >_<

1 Reply

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

Answer by lizzyCTS · Oct 13, 2011 at 03:11 PM

I figured out the problem! For networking, you really really need to differentiate dummy characters from the main player. This was my function for SetDirection:

 function SetDirectionState() : void

{ var charDir : Vector3 = characterInputCtrl.GetDirectionVector();

 if (motor.canControl)

 {

     // Are we moving forward?

     if (charDir.z > 0.1)

.... The dummy character was probably pretty confused by this considering I disabled the character motor! So, I made a boolean to check if this was a dummy character, then to execute those functions only in the RPC function, not every frame.

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

2 People are following this question.

avatar image avatar image

Related Questions

Multiplayer - OnTriggerEnter2D Help.(Only working on Host, Not on Clients) 1 Answer

Unity MLAPI ServerRPC not getting called 2 Answers

RPC in unity with Photon not working 2 Answers

RPC Calls in 5.1 0 Answers

convert standard firstpersoncharacter into multiplayer 2 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