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 virtualmarc · Sep 14, 2013 at 10:06 PM · networkingrpcnetworkplayerunique-identifiers

Player info for objects in Multiplayer

Hello,

I'm having a multiplayer project.

The Server itself is also a client (so no dedicated server).

When the server starts, I'm loading a map, and creating a palyer object with Network.Instantiate.

When a player joins, I'm also creating an object with Network.Instantiate.

These objects contain the player model, the camera, camera and control scripts and a name tag.

Now with the last there is the problem. The name tag. Everything else works fine.

The problem is: How to identify a player and how to save his name.

My test:

Calling an RPC from the client connecting (or the server on start) to the Server.

The server gets the IP and Port of the player and uses it as an unique identifier, adds this ID and the name into a hashmap.

After that it iterates through the hashmap and sends it all players.

In the name tags on the OnGUI function I'm using the key created form:

 networkView.owner.ipAddress + ":" + networkView.owner.port

to get the name from the hashmap with all names sent from the server.

But all this names messes up.

First: The server dows not have an external ip set in this case so the key is ":0" that is set (The RPC uses NetworkMessageInfo to get the IP and Port).

Other clients get the external IP of the server and try to get the name of this key that doesn't exist.

Second: Is there a client connecting over the local network in a match where some are connecting over the internet, the local client has the internal IP as key, from the external client this player has the IP of the server.

I hope someone understands my problem and has a solution for this problem.

Thanks for any answers!

Edit:

Did an additional test.

I'm now using the NetworkPlayer as String. (Player ID)

When the client model is created I'm sending an RPC call to the server with the Player ID and the Name.

The server saves it in a server player list.

Then it iterates through this list and sends it to all players (RPCMode.AllBuffered).

On the Clients I'm tanking the

 transform.networkView.owner.ToString()

or

 transform.gameObject.networkView.owner.ToString()

to get the owner of this object.

On the server side everything is perfect. All palyers have their matching name.

But on the client side (on every client) all other clients and the server have the name of the server.

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 virtualmarc · Sep 15, 2013 at 12:02 AM

Finally I got it with the solution I wrote in my edit.

Read on another question, that only the server knows the client and that the client has to ask the server for the owner of the networkView.

I made an RPC call to the server with the networkView.viewID.

On the server I got the owner from the NetwoekViewID, read out the name and made an RPC call abck to the client who asked for the name.

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

15 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

Related Questions

How to send BUFFERED RPC calls to specific player? 0 Answers

Get NetworkPlayer from ViewID 1 Answer

Photon (PUN) Type Serialization Error on RPC 2 Answers

Find gameobject by Networkplayer? 2 Answers

Networking: Players being "Perma-hit" 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