• 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 nsmith1024 · May 08, 2014 at 02:05 AM · networkviewid

networkView.viewID what exactly is it for?

Hello,

I'm new to unity, I thought it was going to be a piece of cake, but now I'm t$$anonymous$$nking I bit off more than I can chew.

I'm trying to make an authoritative server game, where the client players send their desired movements to the server, then the server sends back to all clients, the actual movement position information.

When a client connects to the server, the server uses RPC calls to create the player objects on all of the clients. In the player script Awake() function, I create a networkView object, and attach it to the player object dynamically for synchronization. So all player clients are doing t$$anonymous$$s as each new player connects to the game server, so everybody can see everybody else.

The problem I have is when the player client wants to move, the client tries to do RPC call to the server using the dynamically attached networkView, to send the desired movements, but the RPC call fails, giving an error on the SERVER (not the client), that the server cant find the networkViewID.

My code didnt print t$$anonymous$$s error, so I guess it must be code deep inside unity that printed it when it received the RPC message from a client, and tried to match it up with a corresponding networkviewID on the server, when it could not, it printed the error?

I'm just wondering how unity works.... does object "A" on all clients and server have the same networkViewID, and object "B" on all clients and servers have the same ID (but different ID from "A")?

If so, how do networkView objects that are instantiated on clients and server know w$$anonymous$$ch ID to assign themselves so they all match up when t$$anonymous$$s is being done on different computers over the network? Is t$$anonymous$$s done automatically by unity, or do I have to send the ID myself to all networkView objects?? But I cant talk to the objects to tell them w$$anonymous$$ch ID to use, since I dont know the networkID in the first place, since that is apparently needed to talk to the networkView objects! Its like trying to ask someone their name, but you need their name in order to ask them. So that cant be how it works.

My problem is that at first, the player object has no networkView on it. After the object is created, the script on player object dynamically attaches a networkView. Since t$$anonymous$$s is done on all clients, and on the server almost at the same time, how will they all know to assign the same ID to the same objects, so that they can RPC each other?

Also I read somewhere that the "owner ID" is always zero????

Sorry I'm new to unity, and trying to figure it all out. Can anyone give me the inside scoop on all t$$anonymous$$s?

Thanks rough

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

Answer by nastasache · May 08, 2014 at 11:28 AM

To simplify: Owner ID is the mac$$anonymous$$ne instantiating objects. NetworkViewID is object identification number over the network. Yes, an obiect A must have the same networkViewID on all the mac$$anonymous$$nes (server, clients); an object B must have the same networkViewID on all the mac$$anonymous$$nes (server, clients) but different from A. You can do following: - when player connected to the server, generate a networkViewID (on the server) - when send spawn RPC from server to all mac$$anonymous$$nes, provide the value of generated networkViewID as parameter - Instantiate (spawn) the object on all mac$$anonymous$$nes and then overwrite the values of networkViewID of instantiated object with the value received from server.

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

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

A node in a childnode? 1 Answer

Are Shadows a Pro feature? 1 Answer

Converting an Azimuthal Coordinate to Vector3D? 1 Answer

Does Unity support material setting from blender? 1 Answer

Publish and Update Game Online? 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