Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Third Party [Help!] Player Name Chat System - PhotonView.ownerid

Discussion in 'Multiplayer' started by ExbowFTW, Jul 23, 2015.

  1. ExbowFTW

    ExbowFTW

    Joined:
    May 2, 2015
    Posts:
    281
    So, I've been trying to work out a system for names - for people to see other people's names in the network. This is my idea: when Player 1 sets his name as "Bob1", "Bob1" is set as his PhotonView's Owner ID. Then when Bob1 enters the game, his his name text field becomes what the value is of his photonview's owner ID, which is "Bob1". This same thing happens to everyone else.

    This solves the first goal - people can see their own name. However, too see someone else's name, they would need to access the photonview of that player and get that player's ownerID, and then set that to the player's text label.

    This is the code that set's each player's 'originalname', which is the variable that the Text Mesh displays. However I don't know how to access another player's photonview to get their ownerID.

    Code (csharp):
    1.  
    2. voidStart() {
    3. if (photonView.isMine) {
    4. originalname = photonView.ownerId; //Accesses the own player's photonView
    5.  }
    6. if (!(photonView.isMine)) {
    7. originalname =                // How do I make it so that it is the other player's photonView?
    8.  }
    9.  }
    10.  
    Also... does this method even work? is it even possible to change the ownerID? And if so, how?
    Do I just do: ('name' is the variable in which the player's name is stored)
    Code (csharp):
    1.  
    2. photonView.ownerId = name;
    3.  
    Sorry for all the questions ;)

    Thanks,
    Exbow
     
  2. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,062
    Nicknames are supported by PUN and using them should be quite easy.
    It's not used in a demo but take a look at the script ShowInfoOfPlayer. Put on a networked game object (with PhotonView), it can easily show the name of the owner of a GO.

    You can't change the ownerId the way you do it, but you can transfer ownership.
    There is a demo in the PUN package and a brief summary of the feature here:
    http://doc.photonengine.com/en/pun/current/tutorials/ownership-transfer
     
  3. ExbowFTW

    ExbowFTW

    Joined:
    May 2, 2015
    Posts:
    281
    Okay, but most likely I wouldn't need to transfer the ownership since there is the ShowInfoOfPlayer...


    So I would do:
    Code (csharp):
    1.  
    2. originalname = ShowInfoOfPlayer("<gameobjectname>");
    3.  
    Okay, I will use this for the next game I make. ;)

    Any game ideas for me? Specifically MMO's or team-games.

    I don't quite understand how the team system works, either, and how you organize players into teams. I'm pretty new at Photon PUN, so I don't really get that much XD

    Thanks!
     
  4. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,062
  5. ExbowFTW

    ExbowFTW

    Joined:
    May 2, 2015
    Posts:
    281
    Okay thanks :D

    Also, does Photon Chat work for Unity? And if so, how do I integrate it into a game?
     
  6. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,062
  7. ExbowFTW

    ExbowFTW

    Joined:
    May 2, 2015
    Posts:
    281
    Do you know of any good tutorials (that you would recommend) that explain the necessary bits of chat code for a Unity game? Because there are many videos, but are I'm not sure if you know which YouTuber is the best for explaining it.

    Thanks!
     
  8. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,062
    I never got used to tutorial videos myself. You can't search text in those and sometimes it's hard to read the code at all.
    So, I don't know any good Chat Video Tutorial.
    But: Things are not too hard. You just send a few messages, right?
    You can take a look at the Chat Demo in the PUN package. There is a slightly different Chat Demo with new UI in the Photon Unity SDK, too. You can "port" that UI to PUN, if needed. It's not in PUN, because that package also supports Unity 4.3.4, which doesn't have the new UI.
     
  9. ExbowFTW

    ExbowFTW

    Joined:
    May 2, 2015
    Posts:
    281
    Okay :) Thanks! I need your opinion on something... I'm going to create a conversation with u.