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 Ossama · Mar 05, 2011 at 02:26 PM · multiplayerserverrpcdedicated

How to Send RPC from One Client to anther while the server isn't in the same scene

i'm Developing a multiplayer game with dedicated server.

can i send rpc from one client to anther while the dedicated server isn't in the same scene with them?

Comment
Add comment · Show 2
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 AngryOldMan · Mar 05, 2011 at 02:29 PM 0
Share

Can you be in a different scene to a dedicated server and still be connected?

avatar image jc_lvngstn · Mar 25, 2011 at 04:06 PM 0
Share

I'd like to know if this is possible as well. Suppose you had a game where players could be in the same or different scenes. Seems like you would need a different server for each scene, if the server(s) are authoratative.

1 Reply

· Add your reply
  • Sort: 
avatar image
3

Answer by asafsitner · Dec 07, 2011 at 11:13 AM

Yes, you can.

The client and server can be on two different scenes, it doesn't matter. They can even be in two completely different projects.

As long as there is an object on the client that has a script with the same RPC (doesn't have to be the same script, only the signature needs to be the same).

Comment
Add comment · Show 6 · 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 a_taker · Apr 30, 2012 at 12:07 AM 0
Share

Hey, can you be more specific about what you mean by the signatures need to be the same? Is it function signatures or...?

avatar image asafsitner · Apr 30, 2012 at 06:57 AM 1
Share

Function signature, yes. RPCs are sent from a NetworkView component to a NetworkView component of the same viewID, regardless of what the receiving object actually is, so as long as there is an object of the same viewID on the receiving end and it has a script with a RPC that has the same name and parameters (i.e. signature) the RPC will go through properly regardless of scene or even project.

As you can see this is a huge opening for bugs and frustration so always remember to check your viewIDs for uniqueness and allocate/re-allocate them as needed with Network.AllocateViewID. $$anonymous$$eep in $$anonymous$$d though that the last network peer (`NetworkPlayer`) who called Network.AllocateViewID on a NetworkView becomes the owner of that NetworkView so only they can use it to send RPCs and write to the synchronization stream.

Again this is an opening for bugs and unwanted behaviour so remember to validate ownership of NetworkViews.

avatar image superme2012 · Dec 16, 2012 at 02:45 PM 0
Share

Was just reading the post.

I understand the issue and have been looking in to it for a few days now. I'm ai$$anonymous$$g to centralize the master server so the code is not also on the client.

It would be a good idea to clear up the issue, for others to also understand.

You mention an RPC signature, by this do you mean an empty function that is declared for the RPC being available?

For example, this would be the client code?

 function sendToServer(){
      networkView.RPC("serverRPCCall", RPC$$anonymous$$ode.Server, "$$anonymous$$essage From Client");
 }
 
 @RPC
 function serverRPCCall(client$$anonymous$$essage:String){
      //I'm just here for the signature
 }

Correct or Incorrect?

just added this in*

I will do a code test next weekend to check that it works the way I expect. I will post the result and the code, here as an answer.

avatar image Bunny83 · Dec 16, 2012 at 03:19 PM 0
Share

@superme2012: Yes, that's correct. Both the sending and the receiving side need a function with the signature you want to call.

asafsitner is actually partially wrong in the comment above. It's true that the peer that allocates a ViewID (by calling AllocateViewID or by using Network.Instantiate) is the owner of the object. The owner is the only one who can send state synchronisation informations He has the control of this object.

However everybody can send and RPC on this object to everyone else. NetworkViews just establish the link between remote objects and your own version of this objects. One person is the owner, but RPCs can be send over that link either way. The RPC function itself should check who executes it or on which machine it's executed.

Things like SetPlayerName should only be invoked by the owner of the object. See Network$$anonymous$$essageInfo and RPC for more details.

I made a multiplayer game by using only one NetworkView in the whole game. This NetworkView was owned by the server. It was an authoritative server setup so all information was spread by the server. Clients can only use RPCs to communicate with the server / other clients.

avatar image asafsitner · Dec 16, 2012 at 03:22 PM 0
Share

@Bunny83: Strange. I tried that once and couldn't send an RPC through a NetworkView that I didn't own. Can you elaborate more on your setup?

Show more comments

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Unity networking tutorial? 6 Answers

How can I send a mouse click to a server using an RPC? 0 Answers

Is server the sender of RPC? 0 Answers

RPC Call problem 1 gameobject 1 prefab 0 Answers

Unity 3d dedicated server 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