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 /
  • Help Room /
avatar image
0
Question by Sladeth_316 · Jan 19, 2021 at 03:31 PM · listssynchronizationmirror

How to sync variables with mirror?

Hi, im getting issues with my project, im making a dice game and i can't get the dices synchronized.

 public class cacho_player_manager : NetworkBehaviour
 {
     // Start is called before the first frame update
     [Header("Dados")]
     [SyncVar][SerializeField]public List<int> dados=new List<int>{0,0,0,0,0,0};
     
     [Header("Propuestas")]
     [SerializeField] public List<int> propuesta_Local=new List<int>{1,1};
     
     [SyncVar][SerializeField]public List<int> propuesta_Global=new List<int>{0,0};
     [SyncVar][SerializeField] int Jugadores=NetworkServer.connections.Count;
     [SyncVar][SerializeField] int Turno=0;
     void Start()
     {
         Cmdget_dices(5);
         if (isLocalPlayer)
         {
             cacho_HUD.instance.localPlayer = this;
             Update_LHUD();
         }
 
     }
     // Update is called once per frame
     void Update()
     {
         //Update_GHUD();
         //Update_LHUD();
     }
     [ClientRpc]
     internal void Update_GHUD(){
             cacho_HUD.instance.Cantidad_G.text=""+propuesta_Global[0];
             cacho_HUD.instance.Pinta_G.sprite = Resources.Load<Sprite>("Imagenes/Cara_Dados/"+propuesta_Global[1]);
     }
     internal void Update_LHUD(){
         if (isLocalPlayer)
         {
             cacho_HUD.instance.Cantidad_L.text=""+propuesta_Local[0];
             cacho_HUD.instance.Pinta_L.sprite = Resources.Load<Sprite>("Imagenes/Cara_Dados/"+propuesta_Local[1]);
         }
     }
     [Command]
     public void Cmdget_dices(int cantidad_de_dados){
         newdices(cantidad_de_dados);
     }
     public void newdices(int cantidad_de_dados){
         for (int i = 0; i < cantidad_de_dados; i++)
         {
             dados[i]=Random.Range(1, 7);
         }
         dados[5]=cantidad_de_dados;
     }
     [Command]
     public void Cmdsubmit_apuesta(){
         if(cacho_rules.Validar_propuesta(propuesta_Local,propuesta_Global)){
             Debug.Log("Verdadero");
             propuesta_Global=new List<int>(propuesta_Local);
             Update_GHUD();
         }
         Debug.Log("Falso");
         
     }
     internal void submit_a(){
         Cmdsubmit_apuesta();
     }
     internal  void cantidad(int x){
         if (isLocalPlayer)
         {
             propuesta_Local[0]=(x+propuesta_Local[0])%11;
             if(propuesta_Local[0]<0){propuesta_Local[0]=0;}
              Update_LHUD();
         }
     }
     internal  void pinta(int x){
         if (isLocalPlayer)
         {
             propuesta_Local[1]=(propuesta_Local[1]+6+x)%6;
             if(propuesta_Local[1]==0){propuesta_Local[1]=6;}
              Update_LHUD();
         }
     }
 }
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

0 Replies

· Add your reply
  • Sort: 

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

155 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

Related Questions

Unity Mirror OnStartServer spawn GameObjects 1 Answer

What is the best way to send data from a client to the server using Mirror? 1 Answer

My SyncVar resets each time a client joins. 0 Answers

I'm getting an error: "AudioClip can't be deserialized because it has no default constructor" 1 Answer

Having problems with multiplayer syncing 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