I have a game in which I two players are given the same set of fruit. When one of the players (either the masterclient or the other player) taps on the fruit it should be destroyed from both scenes.
Now what is happening is that this is working ONLY on the masterclient’s side; therefore, if I tap on an apple, the instantiated apple on both devices is destroyed. This is done in real-time using photon.
On the other hand if I tap from the other client, nothing happens to the fruit.
Can somebody explain please, on how I can destroy the fruit, irrelevant on who’s the owner or not?
This is the code:
if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began)
{
Ray ray = mainCamera.ScreenPointToRay(Input.GetTouch(0).position);
RaycastHit hitInfo;
if (Physics.Raycast(ray, out hitInfo, Mathf.Infinity))
{
if (hitInfo.transform.gameObject.tag == "Banana")
{
//score += Random.Range(1, 3);
// aud2.PlayOneShot(fruitPress);
PhotonNetwork.Destroy(hitInfo.transform.gameObject);
// instantiatedFruit.Remove(hitInfo.transform.gameObject);
// alreadyPlayed = false;
}
}
}
Thanks!