void Update() { if (Input.GetMouseButtonDown(0)) { DusmanSec(); } if (Input.GetButtonDown("1")) { if (secilenBirim != null) { TemelSaldiri(); } } void DusmanSec() { Ray isin = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit vurus; if (Physics.Raycast(isin, out vurus, 10000)) { if (vurus.transform.tag == "düşman") { secilenBirim = vurus.transform.gameObject; dusmanDurumKodu = secilenBirim.transform.gameObject.transform.GetComponent <DusmanDurumu>(); } } } void TemelSaldiri() { dusmanDurumKodu.AlinanHasar(10); } }
void Awake() { oyuncu = GameObject.FindGameObjectWithTag("Player"); //Etiketi oyuncu olan oyun nesnesini bulduk. if (saglik != null) { saglik = GetComponent <IleriSaglik>(); } else { Debug.Log("Boş referans beklentisi"); } dusmanSagligi = GetComponent <DusmanDurumu>(); // Düşmanın sağlığını belirler. anim = GetComponent <Animator>(); // Animator bileşenini etkinleştirdik. }
void Start() { patlamaEtkisi = new GameObject("patlama", typeof(Rigidbody), typeof(BoxCollider), typeof(MeshRenderer)); hedef = GameObject.FindGameObjectWithTag("enemy").transform; dusman = hedef.gameObject.GetComponent <DusmanDurumu>(); }
void Start() { hasarlar = GetComponent <DusmanDurumu>(); hedef = GameObject.FindGameObjectWithTag("enemy").transform; rb = GetComponent <Rigidbody>(); }