Quantcast
Channel: Latest Questions on Unity Answers
Viewing all articles
Browse latest Browse all 171066

problem Multiplayer score counting towards all players

$
0
0
I have an issue with my game where I have a score system setup where you pickup and item it adds +1 to your score kills the pickup and updates a GUIText with the player score this works fine until I add a second player over the network. Now when a pickup is collected it will be added to both players scores. There is probably something simple I have overlooked I am not a programmer so I am learning as I go. I thought using if (networkView.isMine)may have helped but I had no luck. If someone could possibly help me understand what is causing the issue or point me in the right direction it would be appreciated. I have added my score code below hopefully I have provided enough information. thanks This is attached to a player prefab which includes a static variable to be accessed by my GUIText script static var scoreText = 0; function OnTriggerEnter( other : Collider ) { Debug.Log("OnTriggerEnter() was called"); if (other.tag == "PickupBasic") { Debug.Log("Other object is a pickup"); scoreText += 1; Destroy(other.gameObject); } } GUIText script basically just getting the scoreText for the other script var myPlayer : GameObject; function Update(){ GetComponent(GUIText).text = (PickupScore).scoreText.ToString(); Debug.Log("added value"); }

Viewing all articles
Browse latest Browse all 171066

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>