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 Aria-Lliane · Aug 06, 2014 at 08:53 PM · networkrpcloginviewid

How to manage viewIDs?

Let's say you already have a small networking game, 2 different scenes (atleast).

Scene 1 is a main menu kinda thing that asks for username and pass, that leads to diferent things, one of them is scene 2.

Your server is running scene 2, and it has a "manageLogins" script attached to a "ServerGameObject" (aka The Matrix), for (atleast) checking login passwords that users put in scene 1's menu.

Once your scene 2 becomes big enough you start thinking: "f*ck! why do i have so many scripts on this god damned object! I cant even call this organization! lets break it into several objects" and so you end up having a Server Object, an NPC manager object, etc. And so now you got tons of RPCs Spread on several objects (with several viewIDs).

Meanwhile any user, initially, only has the right to make an RPC call from it's initial menu asking for login credentials. (viewID's conflict here)

While on the client viewID '1' belongs to the "initmenu"(cause it's the only one), on the server there isn't even an "initmenu", viewID '1' belongs to some other object.

How can I manage the ID's of the viewID's in order to make it work? What happens when I have several maps going on?

Comment
Add comment
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

1 Reply

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

Answer by Aria-Lliane · Aug 13, 2014 at 10:53 PM

I found my own solution yet again:

When you need to call an RPC on another object, you can call it like this:

 //this is an example
 GameObject ServerObject = GameObject.Find ("ServerGameObject");
 ServerObject.networkView.RPC ("RequestCastingSpell",RPCMode.Server, spellID, castPosition);

Sadly i did not find a solution where i would NOT have to have a "ServerGameObject" on the first scene. Just make sure the ID of the object match and all will be fine.

Comment
Add comment · Show 1 · 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 Bunny83 · Aug 13, 2014 at 11:26 PM 0
Share

In general you only have two options how to establish communication:

  1. using a common object in the first scene which has a NetworkView attached. That way you always have a reliable link to all others.

  2. using Network.Instantiate on the server to create an instance of a prefab which has a NetworkView attached.

I usually go for option 1. $$anonymous$$eep in $$anonymous$$d you can turn your RPC object into a singleton, so you can access it easily from everywhere.

Also don't forget to set a level prefix when loading a new scene to prevent ViewID mixups. You should also read the Level loading example page. Turning off the message queue usually prevent any old messages to create errors in new loaded scemes.

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

21 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 avatar image

Related Questions

RPC called with a viewID, reaching server with a different viewID 1 Answer

How to get a gameObject having viewID? 1 Answer

ViewID + Sending Messages 1 Answer

Can't send RPC function since no connection was started 1 Answer

Small RPC Code Not Working 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