Photon“失败了网络回形'游戏对象
using System;
using System.Collections;
using UnityEngine.SceneManagement;
using System.Collections.Generic;
using Photon.Realtime;
using Photon.Pun;
public class Player1 : MonoBehaviour
{
public int maxHealth = 100;
public int currentHealth = 100;
PhotonView myPhotonView;
public HealthBar healthBar;
public GameObject Controller;
void Start()
{
healthBar.SetMaxHealth(maxHealth);
}
public void TakeDamage(int damage)
{
if (!myPhotonView.IsMine)
{
currentHealth -= damage;
Debug.Log(currentHealth);
if (currentHealth <= 0)
{
Kill();
}
}
}
public void Kill()
{
if (!myPhotonView.IsMine)
{
PhotonNetwork.Destroy(gameObject);
}
}
void OnCollisionEnter(Collision collision)
{
myPhotonView = GetComponent<PhotonView>();
if (!myPhotonView.IsMine)
{
{
if (collision.gameObject.tag == "Bullet")
{
Destroy(collision.gameObject);
TakeDamage(20);
Debug.Log("Collision Detected");
}
if (collision.gameObject.tag == "Bullet2")
{
Destroy(collision.gameObject);
TakeDamage(40);
Debug.Log("Collision Detected");
}
if (collision.gameObject.tag == "Bullet3")
{
Destroy(collision.gameObject);
TakeDamage(50);
Debug.Log("Collision Detected");
}
if (collision.gameObject.tag == "Bullet4")
{
Destroy(collision.gameObject);
TakeDamage(100);
Debug.Log("Collision Detected");
}
}
}
}
}
每当我尝试删除死亡的播放器时,我都会遇到此错误。
都无法“网络删除” GameObject。客户既不是所有者,也不是Masterclient接管离开的所有者:在玩家(克隆)上查看(0)2001
我尝试过所有工作来制作这项工作,这只是我不知道它与Photon View有关系,但我只是无法弄清楚。
using System;
using System.Collections;
using UnityEngine.SceneManagement;
using System.Collections.Generic;
using Photon.Realtime;
using Photon.Pun;
public class Player1 : MonoBehaviour
{
public int maxHealth = 100;
public int currentHealth = 100;
PhotonView myPhotonView;
public HealthBar healthBar;
public GameObject Controller;
void Start()
{
healthBar.SetMaxHealth(maxHealth);
}
public void TakeDamage(int damage)
{
if (!myPhotonView.IsMine)
{
currentHealth -= damage;
Debug.Log(currentHealth);
if (currentHealth <= 0)
{
Kill();
}
}
}
public void Kill()
{
if (!myPhotonView.IsMine)
{
PhotonNetwork.Destroy(gameObject);
}
}
void OnCollisionEnter(Collision collision)
{
myPhotonView = GetComponent<PhotonView>();
if (!myPhotonView.IsMine)
{
{
if (collision.gameObject.tag == "Bullet")
{
Destroy(collision.gameObject);
TakeDamage(20);
Debug.Log("Collision Detected");
}
if (collision.gameObject.tag == "Bullet2")
{
Destroy(collision.gameObject);
TakeDamage(40);
Debug.Log("Collision Detected");
}
if (collision.gameObject.tag == "Bullet3")
{
Destroy(collision.gameObject);
TakeDamage(50);
Debug.Log("Collision Detected");
}
if (collision.gameObject.tag == "Bullet4")
{
Destroy(collision.gameObject);
TakeDamage(100);
Debug.Log("Collision Detected");
}
}
}
}
}
Whenever I try to remove a player that has died I get this error.
Failed to 'network-remove' GameObject. Client is neither owner nor masterClient taking over for owner who left: View (0)2001 on Player(Clone)
I've tried everything to make this work it just won't I know it has something to do with photon view but I just can't figure it out.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
因为您不是对象或主客户端的所有者,因此您无法摧毁该对象。
您可以将RPC发送给主客户端,以询问主销毁它。
Because you are not owner of object or master client, so you can not destroy that object.
You can send RPC to master client to ask master destroy it.