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 Firedan1176 · May 30, 2014 at 04:20 PM · multiplayerphotonsynchronization

Photon Networking - What function(s) are called when a player (not me) is spawned?

I'm trying to make a system to place a player's name above them when they spawn. I have PhotonNetwork.owner for their name, the only problem is the most efficient way to update their name. Using something like:

somePlayerThatIGrabbedInAForeachLoop.TextMesh.text = PhotonNetwork.owner;

that would work, but since it's in update, that seems a little inefficient. I'd prefer to have one function like void UpdatePlayerNames() where it just uses a foreach loop to grab all players and updates all their names so when a player joins or a player changes their names it will update all names (which isn't a big deal if it does them all, not just the one that changed). Anyone got such function that is called when a player joins the lobby/game/server? THanks

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

2 Replies

· Add your reply
  • Sort: 
avatar image
6
Best Answer

Answer by AlucardJay · May 31, 2014 at 03:46 AM

Edit : https://doc-api.photonengine.com/en/pun/current/class_photon_network.html


The best thing to do is check the PDF that comes with the package. Here are some common functions called by Photon :

 //  Photon Auto Called Functions
 //  ----------------------------------------------------------------------------------------------
 
 
 // OnJoinedLobby() - called when the Photon Network is connected to with ConnectUsingSettings
 function OnJoinedLobby() 
 {
     Debug.Log( "OnJoinedLobby() : Hey, You're in a Lobby ! " + PhotonNetwork.PhotonServerSettings.ServerAddress );
 }
 
 
 // called when a room is created by the player
 function OnCreatedRoom()
 {
     Debug.Log( "OnCreatedRoom() : You Have Created a Room : " + PhotonNetwork.room.name );
 }
 
 
 // called when a room is joined by the player
 function OnJoinedRoom()
 {
     Debug.Log( "OnJoinedRoom() : You Have Joined a Room : " + PhotonNetwork.room.name );
 }
 
 
 // OnPhotonRandomJoinFailed() - called when JoinRandomRoom() fails, no rooms available
 function OnPhotonRandomJoinFailed()
 {
     Debug.Log( "OnPhotonRandomJoinFailed() : No existing rooms ...." );
 }
 
 
 function OnPhotonPlayerDisconnected( other : PhotonPlayer )
 {
     Debug.Log( "OnPhotonPlayerDisconnected() " + other.name ); // seen when other disconnects
 }
 
 
 function OnConnectedToMaster()
 {
     Debug.Log( "OnConnectedToMaster()" ); // havn't seen this yet
 }
 
 
 function OnMasterClientSwitched() // definitely seen when the host drops out, not sure if it's when becoming master or just when switching
 {
     Debug.Log( "OnMasterClientSwitched()" );
     
     if ( PhotonNetwork.isMasterClient ) 
     {
         Debug.Log( "isMasterClient " + PhotonNetwork.isMasterClient ); // called before OnPhotonPlayerDisconnected
     }
 }
 
 
 function OnPhotonPlayerConnected( other : PhotonPlayer )
 {
     Debug.Log( "OnPhotonPlayerConnected() " + other.name ); // not seen if you're the player connecting
 }


Comment
Add comment · Show 7 · 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 Firedan1176 · May 31, 2014 at 09:58 PM 0
Share

Thanks, this really helped! On line 33 you said OnPhotonPlayerDisconnected(). I wonder if there's one for OnPhotonPlayerConnected().

avatar image AlucardJay · Jun 01, 2014 at 12:20 AM 0
Share

Yep, line 56 (not seen if you're the player connecting). Sorry for the poor layout, this was a quick copy and edit from my first Photon project. I'm sure there's more listed in the PDF, but these are the ones I use the most.

avatar image IAMBATMAN AlucardJay · Oct 09, 2015 at 03:05 AM 0
Share

Is there a OnPhotonPlayerConnectedToRoom() ?

avatar image Whiteleaf IAMBATMAN · Jan 18, 2016 at 05:07 AM 0
Share

OnJoinedRoom();

I'm not sure if that's what your looking for, but it happens when the client connects to a room.

avatar image Firedan1176 · Jul 02, 2014 at 05:49 AM 0
Share

You are just a life-saver! Thanks!

avatar image superme2012 · Oct 16, 2015 at 07:24 AM 0
Share

Link is dead!

avatar image AlucardJay superme2012 · Jan 18, 2016 at 08:09 PM 0
Share

Photon Updated their website. Answer has been updated with working link : https://doc-api.photonengine.com/en/pun/current/class_photon_network.html

avatar image
0

Answer by sarusian · May 30, 2014 at 05:05 PM

Try working with PhotonTarget.AllBuffered, see if that helps, I believe creating a public void, followed bby some kind of if statement may work

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 Firedan1176 · May 31, 2014 at 02:31 AM 0
Share

That's what I'm thinking, I didn't want to have to constantly check to see if someone joined, and I just didn't know if there was already a function that is called by Photon when someone joins.

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

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

Related Questions

Sending (and receiving) player names with Photon Networking 0 Answers

photon player freak out! 1 Answer

Photon scene objects not players! 1 Answer

Getting an "Unknown Resolve Error" with Photon.MonoBehaviour 1 Answer

Snychronize player's name over Photon? 2 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