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