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 aqib-nawaz-003 · Oct 30, 2017 at 08:49 AM · multiplayerunity5multiplayer-networkingsynchronizationsynchronize

multiplayer variable synchronization problem

Hello All, I am new to unity multiplayer and i am have a problem getting other player in network i want to get other player and enable or disable other players components or children.

I attached the code and in code i comment the requirments

please let me know if you did not get the answer Advance Thanks For The Help

 using System.Collections;
 using UnityEngine;
 using UnityEngine.UI;
 using UnityEngine.Networking;
 
 public class ScoreManager : NetworkBehaviour
 {
     private static ScoreManager instance;
     public static ScoreManager Instance {
         get {
             return instance;
         }
     }
 
     [SyncVar]
     public int score;
     [SyncVar]
     public int grass = 1;
     [SyncVar]
     public bool failed;
     [SyncVar]
     public bool complete;
     public Text MyScoreText;
     public Text MyGrassText;
     public Text OppenentScoreText;
     public Text OppenentGrassText;
     public GameObject CompletePanel;
     public GameObject FailedPanel;
     public GameObject PlayPanel;
 
     void Awake ()
     {
         instance = this;
     }
 
     void Update ()
     {
         MyGrassText.text = grass.ToString ();
         MyScoreText.text = score.ToString ();
         //and other player grass text and score text
     }
 
     void OnTriggerEnter (Collider other)
     {
         if (other.gameObject.tag == "hurdle") {
             print ("GameOver....! :P");
             failed = true;
             //here i want to true other player complete = true;
             //and also want to call other player Check();
             Check ();
         }
         if (other.gameObject.tag == "Single") {
             print ("Single....! :P");
             score += 10 * grass;
         }
         if (other.gameObject.tag == "Double") {
             print ("Double....! :P");
             score += 20 * grass;
         }
         if (other.gameObject.tag == "Grass") {
             print ("Grass....! :P");
             grass++;
         }
     }
 
     void Check ()
     {
         if (complete) {
             CompletePanel.SetActive (true);
             PlayPanel.SetActive (true);
         }
         if (failed) {
             FailedPanel.SetActive (true);
             PlayPanel.SetActive (false);
         }
     }
 }
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

Answer by x4637x · Oct 30, 2017 at 09:23 AM

You only have this public Text MyScoreText; in your ScoreManager's instance. And it is not tagged with [SyncVar], so I guess what you need is something like a list<string> to contain all players scores and sync that list between each player.

Comment
Add comment · Show 4 · 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 aqib-nawaz-003 · Oct 30, 2017 at 10:02 AM 0
Share

@x4637x I just want to show other players score. and just want to call other player public function that when trigger tag is hurdle then i can call my check function and also other player function

avatar image x4637x aqib-nawaz-003 · Oct 30, 2017 at 10:21 AM 0
Share

This tutorial might expand it to you how to do that. Check how she displays different player's name.

avatar image aqib-nawaz-003 · Oct 30, 2017 at 10:03 AM 0
Share

thanks for your considerations stay blessed have a good day

avatar image aqib-nawaz-003 · Oct 30, 2017 at 10:25 AM 0
Share

Thanks man i am checking

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

133 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

Related Questions

How to sync transform of character's bone(spine)? 0 Answers

Unity Netcode: Change Ownership doesn't work for me 0 Answers

Multiplayer - non player object synchronisation 0 Answers

How to sync Class in Multiplayer 1 Answer

Unity NetworkTransformChild - Syncing the Child of a Child 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