Online oyunda yanlış karakter spawn oluyor

hahaha6161

Yoctopat
Katılım
17 Haziran 2023
Mesajlar
1
Daha fazla  
Cinsiyet
Erkek
Online oyun yapıyorum lakin öldürme ile ilgili sıkıntım var. Karakterlerden saldıran kişi hasar yiyen kişinin canını sıfıra indirince normalde ölen kişi tekrar spawn olacak ama benim yazdığımda öldüren kişi tekrar spawn oluyor.

Kod:
using Photon.Pun.Demo.PunBasics;
using Photon.Pun;
using System.Collections;
using System.Collections.Generic;
using TPSBR;
using UnityEngine;

public class EnemyHealth : MonoBehaviourPunCallbacks
{
 public float health;
 // değiştirilen kodlar.
 playermanager playerManager;
 PhotonView PV;

 [HideInInspector] public bool isDead;
 Animator animator;
 private void Awake()
 {
 PV = GetComponent<PhotonView>();
 playerManager = PhotonView.Find((int)PV.InstantiationData[0]).GetComponent<playermanager>();
 }
 private void Start()
 {
 animator = GetComponent<Animator>();

 }
 [PunRPC]
 public void RPC_TakeDamage(float damage)
 {
 if (PV.IsMine)
 return;
 health -= damage;
 if (health <= 0)
 {
 Die();

 }
 else Debug.Log("Hit");
 }

 void Die()
 {
 playerManager.Die();
 }
 /* public void TakeDamage(float damage)
 {
 if (health > 0)
 {
 health -= damage;
 if (health <= 0) Die();
 else Debug.Log("Hit");
 }
 }

 void Die()
 {
 playerManager.Die();
 Debug.Log("Death");
 }*/
}using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
using System.IO;
namespace TPSBR.
{
 public class playermanager : MonoBehaviour.
 {
 GameObject Controller;
 PhotonView PV;
 void Awake()
 {
 PV = GetComponent<PhotonView>();

 }
 void Start()
 {
 if (PV.IsMine)
 {
 CreateController();

 }
 }
 void CreateController()
 {
 Controller= PhotonNetwork.Instantiate(Path.Combine("PhotonPrefabs", "player"), Vector3.zero, Quaternion.identity,0,new object[] {PV.ViewID});
 }
 public void Die()
 {
 if (Controller != null)
 {
 PhotonNetwork.Destroy(Controller);
 }
 if (PV.IsMine)
 {
 CreateController();
 }
 }
 }
 
Son düzenleyen: Moderatör:
Bu siteyi kullanmak için çerezler gereklidir. Siteyi kullanmaya devam etmek için çerezleri kabul etmelisiniz. Daha Fazlasını Öğren.…