Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 zak666 · Feb 13, 2017 at 12:13 PM · photonscoreboard

Unity Photon game scoreboard (player properties) any clear tutorials?

I have looked around and wand haven't found a clear tutorial how to build a scoreboard in photon. (Kills / deaths) using custom player properties in photon. I can add Kills / deaths to player properties, my problem is displaying the Scores in every player in my game, and display their Score / Name. this should be a very simple thing but theirs no tutorials on it...

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
1
Best Answer

Answer by ChristianSimon · Feb 13, 2017 at 01:18 PM

Hi,

I can add Kills / deaths to player properties

in this case you are already halfway through. Next step is to collect the data and bring it in a format your future scoreboard can work with. A simple solution might a list represented by a single string which contains player names, kills and deaths. For example:

 string scores = string.Empty;
 
 foreach (PhotonPlayer p in PhotonNetwork.playerList)
 {
     scores += p.NickName + " Kills:" + p.CustomProperties["kills"] + " Deaths" + p.CustomProperties["deaths"] + "\n";
 }

You now have a simple list which can be displayed in the OnGUI() function, for example:

 public void OnGUI()
 {
     GUILayout.Label(scores);
 }

This a very simple solution, if you want to make it look more fancy and / or build the UI in the Editor and not from script, you need something similar to collect the player data and make it visible on the UI.

Comment
Add comment · Show 3 · 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 zak666 · Feb 15, 2017 at 04:44 AM 0
Share

Thanks man! (Is their a way to get the highest score and tell that player they are the winner?) winner.setactive (if they have the highest score?)

avatar image ChristianSimon zak666 · Feb 16, 2017 at 09:34 AM 0
Share

There is no function implemented for this, so you need to do the sorting yourself. You can basically do the same as above, but this time you copy the necessary data (I guess it's UserId since it's unique and the score value) to a Dictionary for example and sort it by score afterwards.

To tell others that a client has won the game, you can use RPCs or RaiseEvent calls when adding scores for a local player. There are also other possible ways to achieve what you want, for example let the $$anonymous$$asterClient check the client scores regularly and let him decide to end the game, might be not the best solution. There is no predefined function for this behaviour either.

avatar image Christos_charalambous ChristianSimon · Dec 18, 2018 at 02:51 PM 0
Share

Hey, I have a similar thing and I'm trying to resolve it for a few weeks now, (noobHere)

I want to display on the UI the local client HP left and the enemy HP left but I can't figure out on how to access the other client's remaining HP... I know how to access it with OnGui as you mentioned above but I want something like:

HP (local): 300

Enemy (Other Client): 126.

I have another issue which I haven't begin to solve,

I want with a push of a button to view the other client camera without the UI and back again, is there a way?

avatar image
0

Answer by Jesver · Nov 11, 2019 at 12:04 PM

@ChristianSimon hello I wanted to know how are we adding score to the player I did not find anything to sujuet on google

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

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Score System Problem usying Photon 0 Answers

scoreboard for multiplayer game 0 Answers

Synchronization in Photon, I have a scene where I dont instantiate anything, but I want it to update its status constantly on all clients 0 Answers

For Loop Freezing Client (May be a Photon-related issue) 0 Answers

Photon Server Issue 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