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 m5k · Sep 07, 2012 at 12:06 PM · c#networkingplayerphotonmmo

Player names all displayed as local player

Hello, i am currently working on a simple unity/photon powered multiplayer game. I have set a script to display player names above the heads of all connected players. The script is as follows:

 using UnityEngine;
 using System.Collections;
 
 public class PlayerName : MonoBehaviour {
 
 void OnGUI()
    {
 
          Vector3 offset = new Vector3(0, 3, 0); // height above the target position
          
           Vector3 point = Camera.main.WorldToScreenPoint(transform.position + offset);
          point.y = Screen.height - point.y;
 
           GUI.Label(new Rect(point.x - 35, point.y - 20, 200, 20), PhotonNetwork.playerName);
 
    }
 }


This script is attacked to the instanced player object which has a photonview attached. The script will display names above all connected users, however the name will be that of player belonging to the local client. i.e. if you connect with the player name "guest123", all players will display "guest123" above their heads. Here is a image to illustrate the issue.

alt text

bug.jpg (290.7 kB)
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
2
Best Answer

Answer by tobiass · Sep 12, 2012 at 02:16 PM

PhotonNetwork.playerName is the name of your local player only. Your avatars will already have a PhotonView component attached to them. Per avatar, get this component and display: photonView.owner.name.

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 m5k · Sep 12, 2012 at 09:51 PM 0
Share

Lol, thanks a lot Tobiass, I have tried so many work-arounds yet something so simple fixed the issue :P

avatar image kratosrg m5k · Jan 04, 2014 at 02:40 PM 0
Share

i have same problem, how you solved?

avatar image Link_of_Hyrule · Aug 11, 2013 at 07:01 AM 0
Share

I know this is old but can you post your code for this I've been trying for hours and can't figure out how to get this to work! Thanks.

avatar image AFanOfHammers · Mar 12, 2014 at 06:44 AM 0
Share

Please post the code, or tell us how to set the photonView.owner.name / photonView.name!

avatar image tobiass · Mar 12, 2014 at 10:47 AM 0
Share

SET a user's name with PhotonNetwork.playerName. This is being synchronized across all players in a game. There is a list of players in the room you're in: PhotonNetwork.playerList. Per player in that list you can access the name.

ACCESS any PhotonView owner's name via: pv.owner.name

The PhotonView.name is inherited from $$anonymous$$onobehaviour: http://docs.unity3d.com/Documentation/ScriptReference/$$anonymous$$onoBehaviour.html

avatar image Mickwa · Apr 03, 2015 at 03:16 PM 0
Share

I was using PhotonNetwork.player.name ins$$anonymous$$d of PhotonNetwork.playerName. Wasted an hour to find this ;)

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

11 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

Related Questions

How to instatiate two players simultaneoulsy before loading level 1 Answer

Photon Networking Spawn player 2 0 Answers

Switching weapons in PhotonNetwork 1 Answer

Photon Network instantiate problem when Master changes 0 Answers

When using photon sometimes it fails to find local game object. 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