Skip to content

Instantly share code, notes, and snippets.

@uruskan
Created January 18, 2017 10:39
Show Gist options
  • Save uruskan/e6496a99c4d4b804a33f6f80f673a85b to your computer and use it in GitHub Desktop.
Save uruskan/e6496a99c4d4b804a33f6f80f673a85b to your computer and use it in GitHub Desktop.
Firing Script in c#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Ateş : MonoBehaviour {
public float saldırıHızı = 0.5f;
public int saldırıGücü = 10;
GameObject oyuncu;
bool düsmanMenzil;
float zamanlayici;
Can can;
void Awake(){
oyuncu = GameObject.FindGameObjectWithTag("oyuncu");
can = oyuncu.GetComponent<Can>();
}
void OnTriggerEnter(Collider other){
if(other.gameObject == oyuncu){
düsmanMenzil = true;
}
}
void OnTriggerExit(Collider other){
if (other.gameObject == oyuncu){
düsmanMenzil = false;
}
}
void Update () {
zamanlayici += Time.deltaTime;
if(zamanlayici >= saldırıHızı){
Saldır();
}
if(can.simdikican <= 0){
Debug.Log("Öldün by Ateş Script");
}
}
void Saldır(){
zamanlayici = 0f;
if (can.simdikican > 0){
can.HasarAl(saldırıGücü);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment