我创建的游戏是一款 FPS 游戏,它与 Photon Networking 配合使用 游戏的工作原理是,当玩家在网络上射击另一个玩家并杀死他时,该玩家会生成一枚硬币,这样玩家就可以收集它并为分数加分,
但!!!!
当玩家收集硬币时我遇到的问题会给网络上的所有人加一分
所以
我需要帮助的是让硬币给收集它的玩家一分,而不是给整个网络
我的密码:这是销毁硬币
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 ();
}
}
这是显示点的 GUI
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;
}
}