the game i have created is a FPS game and it works with Photon Networking how the game works, when the player shoots another player on the network and kills him that player spawns a coin so a player can collect it and add a point to the score,
BUT!!!!
The problem i am having when the player collects the coin it adds one point to all the people on the network
SO
what i need help with is get the coin to give one point to the player that collected it and not to the whole network
MY CODE: this is to destroy the coin
public float hitPoints = 100f;
float currentHitPoints;
public GameObject coin;
[RPC]
public void CoinDie(float amt) {
currentHitPoints -= amt;
if(currentHitPoints <= 0) {
CoinDied();
}
}
void CoinDied() {
bl_SaveInfo.coinCount++;
gu.coinCount++;
CoinDestroy CD = GameObject.FindObjectOfType<CoinDestroy>();
CD.KillCoin ();
}
}
this is the GUI that displays the points
using UnityEngine;
using System.Collections;
public class gu : MonoBehaviour {
public static int coinCount = 0;
float respawnTimer = 5;
void OnGUI()
{
string coinText = "Total Coins: " + coinCount;
GUI.Box (new Rect(Screen.width - 150, 40, 130, 30), coinText);
}
void Update(){
respawnTimer -= Time.deltaTime;
}
public void Clear(){
if (respawnTimer <= 0) {
coinCount = 0;
respawnTimer = 5;
}
}
public void CoinCounter (){
bl_SaveInfo.coinCount++;
gu.coinCount++;
}
void ClearScore(){
coinCount = 0;
}
}