私が作成したゲームは FPS ゲームであり、Photon Networking で動作します。プレイヤーがネットワーク上の別のプレイヤーを撃って殺すと、プレイヤーはコインを生成し、プレイヤーはそれを収集してスコアにポイントを追加できます。 、
しかし!!!!
プレイヤーがコインを集めるときに私が抱えている問題は、ネットワーク上のすべての人に1ポイントを追加します
それで
私が助けを必要としているのは、ネットワーク全体ではなく、それを収集したプレーヤーに 1 ポイントを与えるためにコインを取得することです
MY CODE: これはコインを破壊するためのものです
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;
}
}