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 adrianxd123 · Sep 05, 2019 at 01:53 AM · networkingmultiplayeronlineonline game

How do I create an online object counter

I'm sorry for my English if something is wrong, well what happens is that I have decided to create an online horror game, what happens is that I want when a player takes a soul to show it to the other player, apparently the accountant bugea and the other player gets 0/7 and another 5/7 The code is in Spanish Here the script (JS):

 var Almas : int;

 var AlmasLimit = 7;

 var SceneWinGame : String;

 var chatScript : FPSChat;
 
 function OnTriggerEnter(other : Collider){
     if(other.gameObject.tag == "Alma"){
         networkView.RPC("AlmaRecogida", RPCMode.All, Almas);
         Destroy(other.gameObject);
     }
     
 }
 
 function OnGUI(){
     if(networkView.isMine){
         GUILayout.Label("ALMAS: " + Almas + " / " + AlmasLimit);
     }
 }
 
 function Update(){
     if(Almas == 7){
         networkView.RPC("WinGame", RPCMode.All, SceneWinGame);
     }
 }
 
 @RPC
 function AlmaRecogida(alma : int){
     Almas = alma;
     alma += 1;
 }
 
 @RPC
 function WinGame(LoadScene : String){
 
 SceneWinGame = LoadScene;
 Application.LoadLevel("Win_Scene");
 
 }
Comment
Add comment · Show 4
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 JamesLew · Sep 05, 2019 at 03:47 AM 0
Share

Is there a reason you're using old Networking classes as opposed to Unet?

avatar image adrianxd123 JamesLew · Sep 05, 2019 at 05:26 PM 0
Share

if what happens is that I get used to the old system and also that the UNET I'm not used to it and I don't adapt 100%

avatar image mehtanitish · Sep 05, 2019 at 10:10 AM 0
Share

Are you using Photon's PUN here?

avatar image adrianxd123 mehtanitish · Sep 05, 2019 at 05:27 PM 0
Share

I am not using photon

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by adrianxd123 · Sep 06, 2019 at 12:03 AM

PLEASE I NEED HELPPP!!!!

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 mehtanitish · Sep 06, 2019 at 05:05 AM

Hi,

I have implemented an online score counter in my game where I used Photon's PUN. I have few questions before I can help you. - What type is this networkView and what object does it reference to? - What engine are you using for multiplayer, like PUN, UNET or anything else? - And the script you have pasted above is on your multiplayer object? - Are you able to see counter doing fine on one client but not on another? - Is this counter value binded to your Online player object? so in that case each client shows two player objects and hence two counters, correct me if I am wrong.

Thanks

Comment
Add comment · Show 8 · 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 adrianxd123 · Sep 06, 2019 at 01:34 PM 0
Share

The engine I use is the old raknet system, and the script above has been pasted on the player and on one client it works and the other does not, I have already tried everything that came to $$anonymous$$d and I no longer have left more ideas if you could help me it would be the best

avatar image mehtanitish adrianxd123 · Sep 06, 2019 at 01:57 PM 0
Share

What type is this networkView and what object does it reference to?

avatar image mehtanitish adrianxd123 · Sep 06, 2019 at 02:02 PM 0
Share

You mentioned on one client it works, say two players A and B are connected on two clients, Client 1 is player A and Client 2 is player B. Player A took 5 souls so its counter on Player A is 5 for Client 1 but for Client 2 Player A shows 0. Is this right? Or You see count 5 on both clients for Player A but 0 on player B?

avatar image adrianxd123 mehtanitish · Sep 06, 2019 at 02:11 PM 0
Share

I do not understand you very well with the networkView, and above all it is exactly what happens to me, one player takes a soul and the other does not get that he has picked it up

Show more comments

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

214 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 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 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 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 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 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 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 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 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

How to implement online multiplayer in a simple 1v1 game? 2 Answers

Unity networking tutorial? 6 Answers

Should I be using peer-to-peer networking for my 1v1 game? 1 Answer

Unity Multiplayer 1 Answer

Networking - 1on1 based on Player's level 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