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 Unit-E · Jul 02, 2014 at 10:02 PM · networkingserverrpcclientnetworkview

Networking between projects: how to send ViewIDs?

Closest similar issue I can see is here, but it doesn't address my problem: http://answers.unity3d.com/questions/579459/networking-between-two-different-projects.html

I want to have a project that runs a dedicated server for our game (which lives in another project). The dedicated server project is a separate project because it has to be as lean as possible in terms of CPU and Memory use, needs none of the assets from the game, and runs in headless mode.

Both projects have an object called "server" with a networkView attached. Both projects have an object called "client" with a networkView attached. Both projects have a player prefab with a networkView attached, which is instantiated as players load in.

The client and server can connect. The catch-22 is that neither side can send RPCs to one another because the ViewIDs don't match, and I don't know how to tell either side what the correct ViewIDs are without sending an RPC. OnPlayerConnected and OnConnectedToServer do not transmit this information afaik.

The errors I get are (with generic variables):

-View ID xxx not found during lookup. Strange behaviour may occur

-Could't invoke RPC function 'yyy' because the networkView 'xxx' doesn't exist

Is there a way to communicate ViewIDs between separate client and server projects?

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
0
Best Answer

Answer by Unit-E · Jul 08, 2014 at 10:23 PM

Found a workaround with help with another developer. The problem is that Unity seems to assume that all networking will be done within a single project, even though the engine gives you the option to start dedicated and headless servers.

The workaround is to delete all NetworkViews in your project except for one, which should be attached to an indestructible gameobject. Unity will assign a "scene" NetworkViewID to this NetworkView of "0" (sometimes 1), and as long as there is a matching NetworkViewID of 0 (or 1) on both server and client, you can generate the other NetworkViews you need with AddComponent and then pass the initial RPCs needed to establish your network through the object with the NetworkViewID #0(1) (Unity will complain about a network object going missing, but it allows you to continue). You have to do it this way because you can't allocate NetworkViewIDs from the server without RPCs (for which you need a working and matching NetworkView), and you can't manually set the NetworkViewID scene number (for no apparent reason).

Probably the best method of doing this is to create a unitypackage from a prefab of this network object, which may allow you to avoid the warning as well if everything is identical. I also had to include a bit of code to re-assign new NetworkViewIDs on objects if newly-allocated IDs matched "#0" (Unity will still allocate IDs that are built into the scene).

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

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

Networking: RPC To Specific Player? 1 Answer

Network RCP between client server projects 0 Answers

Is server the sender of RPC? 0 Answers

Unity networking tutorial? 6 Answers

How do I change networkView ownership of a Rigidbody by clicking on it? 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