Quantcast
Viewing latest article 7
Browse Latest Browse All 36

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"); }

Viewing latest article 7
Browse Latest Browse All 36

Trending Articles