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
1
Question by $$anonymous$$ · Nov 10, 2014 at 07:37 AM · fpsphotonnamemmo

Photon Network MultiPlayer names Help C#

The title says what I am trying to do. I have read through the Photon API, and tons of threads, but I still can not for my life get names to work. So this is what I currently have.

When you log on, I have this script.

 using UnityEngine;
 using System.Collections;
 
 public class SetName : MonoBehaviour {
 
     private bool setname = false;
 
     public GameObject Menu;
 
     // Use this for initialization
     void Start () {
     
     }
 
     void OnGUI(){
 
         if(!(PhotonNetwork.connectionStateDetailed.ToString () == "Joined")){
             return;
         }
 
         if(setname){
             return;
         }
 
         PhotonNetwork.player.name = GUI.TextField(new Rect(0, 0, 100, 100), PhotonNetwork.player.name);
 
         if(GUI.Button(new Rect(Screen.width / 2 + 50, Screen.height/2 -50 , 100, 100), "Enter")){
             if(PhotonNetwork.player.name == ""){
                 Debug.LogError("Enter A Name!");
             }else{
                 Menu.SetActive(true);
                 setname = true;
             }
         }
     }
     
     // Update is called once per frame
     void Update () {
     
     }
 }

Ok, so now lets say my player is called "Bob."

When I spawn my player it's PhotonView displays "Bob," as its name.

From this I can work out that I have set the name properly.

So if I build this and run the game as well as unity, I can try this two players. So in unity I call my player "Player 1", and in the other game "Player 2". If I look in the unity game object list, I can now see both my players. If I click on the player controlled though unity, it is called "Player 1." But when I click on the other one, it says that it has not been named.

What am I doing wrong?

Comment
Add comment · Show 2
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 $$anonymous$$ · Nov 12, 2014 at 12:38 AM 0
Share

Any one? I am currently really stuck on this, and I have been trying for the last two days to get it to work. Any help would be great.

avatar image $$anonymous$$ · Nov 14, 2014 at 07:49 AM 0
Share

Really, no one?

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Baenor · Nov 24, 2014 at 08:20 AM

Honestly i don't think it's an error. If you don't serialize the name, or if you don't use an RPC it's normal that YOU as the Unity Editor don't see changes that happened in other game istances.

I can ensure you that everything will be going to be fine, if you script everything correctly because when you are doing for example a chat script, or a shooting script, you will use an RPC function that will be executed in every instance with the parameters that you set from one....

i hope i helped you

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 $$anonymous$$ · Nov 28, 2014 at 09:50 PM 0
Share

Would it be a good idea to run an RPC when a player joins containing the name? Photon network contains a player name function, but have not been able to get it to work. Is there a tutorial that I have missed that explains how to use the photon name function? I have been able to get the names working, by using the serialise function, but I am sure there is a more appropriate way of getting player names.

avatar image
0

Answer by tobiass · Dec 02, 2014 at 09:17 AM

You only have to set PhotonNetwork.playerName to set "this client's" user's name. This is synchronized automatically in a room.

Per networked object, you can get the PhotonView component and access the owner.name.

Take a look at ShowInfoOfPlayer.cs (in newer PUN packages). It's a component which you could add to a character prefab.

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

Answer by InfernoZYB · Mar 02, 2015 at 06:50 AM

A little late but this script works fine all you gotta do is make a text mesh and assign it.

 public TextMesh text;
 
     // Use this for initialization
     void Start () {
 
         text.text = photonView.owner.name;
     }
     
     // Update is called once per frame
     void Update () {
     
     }
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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

'MonoBehaviour' does not exist in the namespace 'Photon'.. 1 Answer

Proton Integration w/Unity Tutorials 1 Answer

How To Setup Character To Benefit FPS 2 Answers

Problem with UFPS and photon 1 Answer

Photon Network Muzzleflash 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