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 /
This post has been wikified, any user with enough reputation can edit it.
avatar image
0
Question by Seerix · May 27, 2014 at 12:34 PM · rpc

Odd behaviour when sending rpc from client to server

I'm creating a turn-based board game with different phases. I have succeeded in synchronizing movements and turns without much hassle.

This code lets the server know when all the players have finished their moves. This one works just fine.

 public void setDoneMoving() {
     if (Network.isServer)
         rpcSetDoneMoving(Network.player);
     else
         networkView.RPC("rpcSetDoneMoving", RPCMode.Server, Network.player);
 }
 [RPC]
 private void rpcSetDoneMoving(NetworkPlayer player) {
     if (this.members.ContainsKey(player.guid)) {
         this.members[player.guid].setReady(true);
     }
 
     bool nextPhase = true;
     foreach (LobbyGuestScript.Member m in this.members.Values) 
         if (m.getReady() == false)
             nextPhase = false;
 
     if (nextPhase)
         this.setNextPhase(Phase.Board);
 }

This code notifies the server when the board has finished performing actions.

 public void addMovingConveyor() {
     if (Network.isServer)
         rpcAddMovingConveyor(Network.player);
     else
         networkView.RPC("rpcAddMovingConveyor", RPCMode.Server, Network.player);
 }
 public void setConveyorDoneMoving() {
     if (Network.isServer)
         rpcSetConveyorDoneMoving(Network.player);
     else
         networkView.RPC("rpcSetConveyorDoneMoving", RPCMode.Server, Network.player);
 }
 [RPC]
 private void rpcAddMovingConveyor(NetworkPlayer player) {
     Debug.Log("rpcAddMovingConveyor was called");
 
     this.activeConveyorCount++;
 }
 [RPC]
 private void rpcSetConveyorDoneMoving(NetworkPlayer player) {
     Debug.Log("rpcAddMovingConveyor was called");
 
     this.activeConveyorCount--;
 
     if (this.activeConveyorCount == 0)
         if (this.phase == Phase.Express)
             this.setNextPhase(Phase.Board);
         else
             this.setNextPhase(Phase.Lasers);
 }

Despite being so similar this code does not get called. I've tried having browser, stand-alone and Unity editor for both client and server. The rpc function will only get called when BOTH instances run as Unity editor mode.

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 Seerix · May 27, 2014 at 12:36 PM 0
Share

Ugh. I can't seem to get the code tags right :/

1 Reply

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

Answer by Seerix · May 27, 2014 at 04:17 PM

I managed to fix this issue myself. I decided to leave it alone for a while and focus on different functions first. I then found a related bug in other code which caused the rpc function to fail.

The weird thing about this is that the failing code should not prevent my Debug.Log from being called. This made it look like the function was not being called, except when running both client and server in the Unity editor.

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

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Using RPC over diffrent projects? 1 Answer

supplied parameters doesn't match the rpc declaration 1 Answer

How to import the object from server to unity 2 Answers

RPC setName() not working correctly 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