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 DvKrane · Jan 26, 2014 at 01:57 AM · networkingmultiplayerscorebadumna

View PvP scores on screen in real-time

Could someone point me in the right direction as to how I'd be able to implement a PvP multiplayer feature into my game?

Here's a little background on how the game is set up:

  • Its a 2D game where you simply tap on gameObjects to gain points, and after one has been tapped, it destroys itself and spawns a new clone in another location of the screen.

  • It's a multi-platform game for Android and iOS.

  • The main camera in all scenes doesn't move at all, and the player controller is merely an empty gameObject with an attached script.

  • I want the players to be able to see the other person's score in real-time, but I don't want them to be playing on the same field because since it's a tap based game, it would throw the two players off to see gameObjects disappearing from their view and reappearing randomly. I've attached a concept image below. alt text

  • I'm using the Badumna Networking System and will incorporate a working log-in system, however I am willing to change the way I set up my networking because I haven't started the multiplayer/networking feature yet. I'm just asking for a solid way to make the feature work the way I stated above in bold.

I've only researched the Networking capabilities of Unity. I have experience in UnityScript and C# but I have no idea how to script the networking components which is my reason for using Badumna. This is my first major Unity project and I've done a lot with it. Multiplayer is the last part of my game that needs to be done before I release a beta version.

Any help on getting this to work will be greatly appreciated. I will even put your names in the credits when the game is finished and released. I'll also be starting a thread up in a few days in the community forums for my game if anyone is interested to see what I've been working on.

sketch3.png (29.5 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
0
Best Answer

Answer by Corentin · Jan 26, 2014 at 03:00 PM

I don't know anything with Badumna, but I'd implement this with a single NetworkView, setup like this : observe => None and State Synchronization => Off. This NetworkView Component has to be in a scene object (not created at runtime), so that it will be "shared" (same NetworkView ID) by every client on the server. It won't synchronize anything, since you only want to send scores to the other player. You should use an RPC for this, and use networkView.RPC("SetScore",RPCMode.Others, myScore); define the "SetScore" function like this :

 [RPC]
 void SetScore(int score){
     otherPlayerScore = score;
 }
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 DvKrane · Jan 26, 2014 at 08:03 PM 0
Share

You've pretty much answered my question. I don't even need the Badumna stuff anymore. I've set up the GameObject in the scene, and I know to put that piece of code into my script, but where do I call the networkView.RPC("SetScore",RPC$$anonymous$$ode.Others, myScore); at?

avatar image Corentin · Jan 26, 2014 at 08:39 PM 0
Share

You can call the RPC whenever the score changes (the script will need a reference to the networkView Component). You could define a property for your score and call the rpc in the set function : public int Score(int value){ get {return myScore}; set { myScore = value; networkView.RPC("SetScore",RPC$$anonymous$$ode.Others, myScore);}}

$$anonymous$$aybe a AddToScore(int scoreIncrease) function would be better, that's up to you.

avatar image DvKrane · Jan 27, 2014 at 04:41 AM 0
Share

I placed the call in the update of another controller in the scene and it works, however I don't think it's the most efficient way to send the data because it resends it every single frame. But for now, it will do. Thanks again!

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

19 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

Related Questions

Unity networking tutorial? 6 Answers

On screen scoring in multiplayer 1 Answer

Can you create a Stand alone server for your game? 0 Answers

Networking, players can't see each others movements 1 Answer

Multiplayer ScoreBoard not Updating Correctly 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