Failed to 'network-remove' GameObject because it is missing a valid InstantiationId on view: View (0)0 on AlphaPlayerZombie (scene). Not Destroying GameObject or PhotonViews!
UnityEngine.Debug:LogError(Object)
PhotonHandler:DebugReturn(DebugLevel, String) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonHandler.cs:170)
NetworkingPeer:DebugReturn(DebugLevel, String) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:802)
NetworkingPeer:RemoveInstantiatedGO(GameObject, Boolean) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:2271)
PhotonNetwork:Destroy(GameObject) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonNetwork.cs:1740)
PlayerHealth:RecivedDmg(Int32, PhotonMessageInfo) (at Assets/Fiels/Scripts/Player/PlayerHealth.cs:47)
System.Reflection.MethodBase:Invoke(Object, Object[])
NetworkingPeer:ExecuteRPC(Hashtable, PhotonPlayer) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:1806)
NetworkingPeer:RPC(PhotonView, String, PhotonTargets, Object[]) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:2664)
PhotonNetwork:RPC(PhotonView, String, PhotonTargets, Object[]) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonNetwork.cs:1907)
PhotonView:RPC(String, PhotonTargets, Object[]) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonView.cs:254)
PlayerHealth:PlayerAttack(Int32) (at Assets/Fiels/Scripts/Player/PlayerHealth.cs:33)
AutoWeaponMultiplayer:Update() (at Assets/Fiels/Scripts/Weapons/Multiplayer/AutoWeaponMultiplayer.cs:57)
Вот скрипты:
Скрипт здоров'я игрока:
Синтаксис:
Используется csharp
using UnityEngine;
using System.Collections;
public class PlayerHealth : Photon.MonoBehaviour {
public int MaxHealth;
public int Health;
public EnergyBar HPBar;
public GameObject DeadPlayer;
public GameObject player;
private bool isDie {get {return Health <= 0; }}
void Start () {
}
void Update () {
HPBar.valueMax = MaxHealth;
HPBar.valueCurrent = Health;
NetworkSpawn nspawn = GameObject.Find("!Spawn").GetComponent<NetworkSpawn>();
if(Health <= 0){
nspawn.spawncol.enabled = true;
nspawn.cam.enabled = true;
nspawn.SpawnTimer = 5f;
nspawn.Cconttroller.enabled = true;
nspawn.MoveJoy.enabled = true;
nspawn.TurnJoy.enabled = true;
}
}
public void PlayerAttack(int dmg){
if(isDie)
return;
photonView.RPC("RecivedDmg", PhotonTargets.AllBuffered, dmg);
}
[RPC]
private void RecivedDmg(int dmg, PhotonMessageInfo info){
if(isDie)
return;
Health -= dmg;
if(!PhotonNetwork.isMasterClient)
return;
if(isDie){
PhotonNetwork.Destroy(gameObject);
PhotonNetwork.Instantiate(DeadPlayer.name,transform.position,transform.rotation, 4);
Storage.kills += 1;
Storage.PlayerMoney += 4000;
}
}
}
using System.Collections;
public class PlayerHealth : Photon.MonoBehaviour {
public int MaxHealth;
public int Health;
public EnergyBar HPBar;
public GameObject DeadPlayer;
public GameObject player;
private bool isDie {get {return Health <= 0; }}
void Start () {
}
void Update () {
HPBar.valueMax = MaxHealth;
HPBar.valueCurrent = Health;
NetworkSpawn nspawn = GameObject.Find("!Spawn").GetComponent<NetworkSpawn>();
if(Health <= 0){
nspawn.spawncol.enabled = true;
nspawn.cam.enabled = true;
nspawn.SpawnTimer = 5f;
nspawn.Cconttroller.enabled = true;
nspawn.MoveJoy.enabled = true;
nspawn.TurnJoy.enabled = true;
}
}
public void PlayerAttack(int dmg){
if(isDie)
return;
photonView.RPC("RecivedDmg", PhotonTargets.AllBuffered, dmg);
}
[RPC]
private void RecivedDmg(int dmg, PhotonMessageInfo info){
if(isDie)
return;
Health -= dmg;
if(!PhotonNetwork.isMasterClient)
return;
if(isDie){
PhotonNetwork.Destroy(gameObject);
PhotonNetwork.Instantiate(DeadPlayer.name,transform.position,transform.rotation, 4);
Storage.kills += 1;
Storage.PlayerMoney += 4000;
}
}
}
Скрипт оружия:
Синтаксис:
Используется csharp
using UnityEngine;
using System.Collections;
public class AutoWeaponMultiplayer : Photon.MonoBehaviour {
public int Damag;
public int CurAmmoCount = 1;
public int MaxAmmoCount = 1;
public int CurCatrige = 9;
public float ReloadTimer = 0.0f;
public float ReloadingTime;
public float skorostrelnost = 0.1f;
private float reloadskorostrel;
public string splash;
public bool CanFire;
public AudioClip Firen;
private RaycastHit Hit;
private UILabel AmmoLabel;
private UILabel Ammo2Label;
void Start(){
}
void Update() {
AmmoLabel = GameObject.Find("AmmoLabel").GetComponent<UILabel>();
Ammo2Label = GameObject.Find("AmmoLabel2").GetComponent<UILabel>();
AmmoLabel.text = "" + CurAmmoCount + "/" + MaxAmmoCount;
Ammo2Label.text = "" + CurCatrige;
if(photonView.isMine){
if(CanFire & reloadskorostrel <= 0){
if (CurAmmoCount>0 & ReloadTimer <= 0) {
reloadskorostrel = skorostrelnost;
audio.PlayOneShot(Firen);
CurAmmoCount = CurAmmoCount - 1;
PhotonNetwork.Instantiate(splash,transform.position,transform.rotation, 0);
Vector3 DirectionRay = transform.TransformDirection(Vector3.forward);
if(Physics.Raycast(transform.position, DirectionRay, out Hit, 100f))
{
if(Hit.rigidbody)
{
Hit.rigidbody.AddForceAtPosition(DirectionRay*400f,Hit.point);
}
if(Hit.transform.GetComponent("AIHealth"))
{
AIHealth AIH = (AIHealth)Hit.transform.GetComponent("AIHealth");
if(AIH.CurAiHealth > 0){
AIH.CurAiHealth -= Damag;
}
}
if(Hit.transform.GetComponent("ItemHealthExplo"))
{
ItemHealthExplo IH = (ItemHealthExplo)Hit.transform.GetComponent("ItemHealthExplo");
IH.PlayerAttack(Damag);
}
if(Hit.transform.GetComponent("PlayerHealth"))
{
PlayerHealth PH = (PlayerHealth)Hit.transform.GetComponent("PlayerHealth");
PH.PlayerAttack(Damag);
}
}
}
}
if (CurAmmoCount==0&CurCatrige>0&ReloadTimer<=0)
{
ReloadTimer = ReloadingTime;
CurCatrige = CurCatrige - MaxAmmoCount;
CurAmmoCount = MaxAmmoCount;
}
if(ReloadTimer>0)
{
ReloadTimer -= Time.deltaTime;
}
if(reloadskorostrel>0)
{
reloadskorostrel -= Time.deltaTime;
}
if(CurAmmoCount == 0 && ReloadTimer<=0)
{
}
}
}
void Fire(){
CanFire = true;
}
void NotFire(){
CanFire = false;
}
}
using System.Collections;
public class AutoWeaponMultiplayer : Photon.MonoBehaviour {
public int Damag;
public int CurAmmoCount = 1;
public int MaxAmmoCount = 1;
public int CurCatrige = 9;
public float ReloadTimer = 0.0f;
public float ReloadingTime;
public float skorostrelnost = 0.1f;
private float reloadskorostrel;
public string splash;
public bool CanFire;
public AudioClip Firen;
private RaycastHit Hit;
private UILabel AmmoLabel;
private UILabel Ammo2Label;
void Start(){
}
void Update() {
AmmoLabel = GameObject.Find("AmmoLabel").GetComponent<UILabel>();
Ammo2Label = GameObject.Find("AmmoLabel2").GetComponent<UILabel>();
AmmoLabel.text = "" + CurAmmoCount + "/" + MaxAmmoCount;
Ammo2Label.text = "" + CurCatrige;
if(photonView.isMine){
if(CanFire & reloadskorostrel <= 0){
if (CurAmmoCount>0 & ReloadTimer <= 0) {
reloadskorostrel = skorostrelnost;
audio.PlayOneShot(Firen);
CurAmmoCount = CurAmmoCount - 1;
PhotonNetwork.Instantiate(splash,transform.position,transform.rotation, 0);
Vector3 DirectionRay = transform.TransformDirection(Vector3.forward);
if(Physics.Raycast(transform.position, DirectionRay, out Hit, 100f))
{
if(Hit.rigidbody)
{
Hit.rigidbody.AddForceAtPosition(DirectionRay*400f,Hit.point);
}
if(Hit.transform.GetComponent("AIHealth"))
{
AIHealth AIH = (AIHealth)Hit.transform.GetComponent("AIHealth");
if(AIH.CurAiHealth > 0){
AIH.CurAiHealth -= Damag;
}
}
if(Hit.transform.GetComponent("ItemHealthExplo"))
{
ItemHealthExplo IH = (ItemHealthExplo)Hit.transform.GetComponent("ItemHealthExplo");
IH.PlayerAttack(Damag);
}
if(Hit.transform.GetComponent("PlayerHealth"))
{
PlayerHealth PH = (PlayerHealth)Hit.transform.GetComponent("PlayerHealth");
PH.PlayerAttack(Damag);
}
}
}
}
if (CurAmmoCount==0&CurCatrige>0&ReloadTimer<=0)
{
ReloadTimer = ReloadingTime;
CurCatrige = CurCatrige - MaxAmmoCount;
CurAmmoCount = MaxAmmoCount;
}
if(ReloadTimer>0)
{
ReloadTimer -= Time.deltaTime;
}
if(reloadskorostrel>0)
{
reloadskorostrel -= Time.deltaTime;
}
if(CurAmmoCount == 0 && ReloadTimer<=0)
{
}
}
}
void Fire(){
CanFire = true;
}
void NotFire(){
CanFire = false;
}
}
Помогите пожалуйста решить проблему.