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 Shawn Miller · Apr 28, 2013 at 03:33 AM · networkingrpcnetworkview

RPC not sending and not giving an error?

So I'm working on a networked game and so far I've had no problems with RPCs aside from random user error, but this one is baffling me. Every iteration of the while loop in BeginReport I get the "Reporting" debug line on the client as intended. On the server, however, "Report Reached The Server" never shows up. I took a look at the stats tab and it was showing only 2 sets of packets being exchanged between the server and client, always the same size and at the same time intervals so most likely handshaking or something but never anything else. I know it's something absolutely stupid but neither myself, nor anyone I've shown can make heads or tails of what's wrong.

The code is below, ignore the somewhat verbose function calls, I was doing testing.

 using UnityEngine;
 using System.Collections;
 
 [RequireComponent(typeof(NetworkView))]
 public class ReportOnLevelLoaded : MonoBehaviour {
   bool receivedConfirmation = false;
   
     void Start () {
       if(Network.isClient) {
           StartCoroutine("BeginReport");
       }
     }
     
   IEnumerator BeginReport() {
     while(!receivedConfirmation) {
       Debug.Log("Reporting");
       networkView.RPC("ReportToServer", RPCMode.Server, Network.player);
       yield return new WaitForSeconds(0.1f);
     }
   }
 
   [RPC]
   void ReportToServer(NetworkPlayer player) {
     Debug.Log("Report Reached The Server");
     LevelLoadedCounter llc = gameObject.GetComponent<LevelLoadedCounter>();
     llc.ReportIn(player);
   }
   
   [RPC]
   public void ServerReceivedReport() {
     receivedConfirmation = true;
   }
 }
Comment
Add comment · Show 9
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 whydoidoit · Apr 28, 2013 at 06:54 AM 0
Share

Does the server have this actual representation of a ReportOnLevelLoaded attached to it? RPCs go to the same object on the server - i.e. the one with the same NetworkViewID.

avatar image Loius · Apr 28, 2013 at 07:28 AM 0
Share

They do? The documentation says an RPC call will call just whatever function it finds. So if you have "Func" on every component, the RPC call will just find the first object with a "Func" function and run that. Says the documentation. $$anonymous$$aybe. I took it at what I thought its word was and wrote around that without testing it.

are you successfully connected (use OnPlayerConnected to quickly check that)?

avatar image whydoidoit · Apr 28, 2013 at 07:48 AM 0
Share

It certainly doesn't call every function on every script with a networkView attached. It has to call on the scripts on the object you are targeting.

avatar image whydoidoit · Apr 28, 2013 at 07:48 AM 0
Share

So if you address this to a non-existent NetworkView, nothing will happen.

avatar image Shawn Miller · Apr 28, 2013 at 10:58 AM 0
Share

@whydoidoit Yes it's there, that was the first thing that I checked. @Loius This is also true, whydoidoit might have used the wrong word but it can call any function on an object which has the same NetworkView. In this way I typically set up 2 scripts, on the same object, one for the server logic and one for the client and make calls back and forth between them.

Show more comments

0 Replies

· Add your reply
  • Sort: 

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

14 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

Related Questions

Is server the sender of RPC? 0 Answers

networkView.RPC() inside a ScriptableObject 1 Answer

Where is a free, helpful tutorial on how to use Unity's networking? 2 Answers

Which is better: NetworkView or RPC? 1 Answer

View ID AllocatedID: # not found during lookup. Strange behaviour may occur 1 Answer


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