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
1
Question by Ignacio 1 · May 05, 2011 at 07:43 PM · networkrpc

RPC buffered calls

Hi! I'm making a small project in order to understand how to work with networking code in Unity. Here's what I'm trying to accomplish: I want to create an executable that displays two buttons (one to start a new server and the other one to join an existing one as a client). The server also has the capability of instantiating a scene using an RPC buffered call and the client should be able to replicate the server's output. Notice that the client should be able to connect to the server anytime (even after the scene instantiation took place).

I did some tests and, although the instantiation is working, there's something wrong with the RPC call. Here's the scenario test: when a client joins a server that has already instantiated the scene, the client doesn't execute the buffered RPC call. If I close the server's window, I get a message on the client (something along the lines of "The server has disconnected from the client") and the RPC call is made (and the scene is appropriately instantiated).

This is my connection script, which is attached to a game object that has a NetworkView component observing it. I simplified it as much as possible, do you mind helping me a little bit in order to determine where's my error? Thanks in advance!

using UnityEngine; using System.Collections;

public class Connection : MonoBehaviour { public Transform Scene; // The prefab that holds the scene we would like to instantiate.

 // Use this for initialization
 void Start () {}

 // Update is called once per frame
 void Update () {}

 void OnGUI()
 {
     GUILayout.BeginArea(new Rect(10,10,200,250));
     if(GUILayout.Button("CREATE SERVER"))
     {
         NetworkConnectionError err = Network.InitializeServer(32,25000,false);
         if(err==NetworkConnectionError.NoError)
         {
             Debug.Log("Server initialized!");
         }
     }
     if(GUILayout.Button("JOIN SERVER"))
     {
         NetworkConnectionError err = Network.Connect("127.0.0.1", 25000);
         if(err==NetworkConnectionError.NoError)
         {
             Debug.Log("Successfully connected to server!");
         }
     }       
     GUILayout.EndArea();

     if(Network.isServer)
     {
         GUILayout.BeginArea(new Rect(10,270,200,250));
         if(GUILayout.Button("INSTANTIATE"))
         {
             Debug.Log("Instantiating scene...");
             NetworkViewID SceneViewID = Network.AllocateViewID();
             networkView.RPC("InstantiateScene", RPCMode.AllBuffered, SceneViewID);
         }
         GUILayout.EndArea();
     }
 }

 [RPC]
 void InstantiateScene(NetworkViewID SceneViewID)
 {
     Transform SceneTransform = Instantiate(Scene, Scene.position, Scene.rotation) as Transform;
     if(SceneTransform==null)
     {
         Debug.Log("SceneTransform is null!");
     }
     NetworkView nView;
     nView = SceneTransform.GetComponent<NetworkView>();
     nView.viewID = SceneViewID;
     Debug.Log("Executing RPC function InstantiateScene");
 }

}

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 Swift_On_Fire · May 23, 2012 at 04:25 PM 0
Share

From what I understand, you seem to be doing things correctly. Not sure what's wrong. I am having an issue with Buffered RPCs as well.

The issue I'm having is that the buffered RPCs are sent to all currently connected clients. When the next client connects, that client receives them also. However, only the first subsequent client to connect gets them. After that, none do.

Are we having similar issues?

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

1 Person is following this question.

avatar image

Related Questions

How To Show instantiated Prefab To New Connected Player? 0 Answers

Network.Instantiate doesn't work for buffered players 1 Answer

Buffered RPCs Only Sent To One New Client 0 Answers

RPC ordering - is it really preserved? 1 Answer

MultiPlayer People Cant See Each Others 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