Skip to content

Instantly share code, notes, and snippets.

@SenpaiRar
Created May 6, 2020 07:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SenpaiRar/f4e19d3697bbbf07dbf82f68a4bab91b to your computer and use it in GitHub Desktop.
Save SenpaiRar/f4e19d3697bbbf07dbf82f68a4bab91b to your computer and use it in GitHub Desktop.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CircleWeapon : Bullet
{
public int DamageValue;
public int Speed;
public float Lifetime;
private void Start(){
StartCoroutine(Lifespan());
}
void FixedUpdate(){
transform.Translate(Vector3.forward*Speed*Time.deltaTime, Space.Self);
}
void OnTriggerEnter(Collider col){
if(col.tag == "Enemy"||col.tag=="Enemy_Bullet"){
col.GetComponent<Entity>().TakeDamage(DamageValue);
}
}
public override int GetDamage(){
return DamageValue;
}
IEnumerator Lifespan(){
yield return new WaitForSecondsRealtime(Lifetime);
Destroy(gameObject);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment