using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Bullet : MonoBehaviour, IAmmunitonHandler
{
[SerializeField]
private float totalTimer;
private float timer = 0;
private float damage = 0;
bool isCurrentlyColliding = false;
[HideInInspector]
public GameObject source;
private void Awake()
{
Physics.IgnoreLayerCollision(6, 6);
}
void OnCollisionEnter(Collision col)
{
//if(col.gameObject.tag != "lowCaliber")
isCurrentlyColliding = true;
HealthSystem temp = col.gameObject.GetComponent<HealthSystem>();
if(temp != null)
{
temp.TakeDamage(damage, source);
}
}
void Update()
{
BulletTimer();
}
public void BulletTimer()
{
timer += Time.deltaTime;
if (timer >= totalTimer|| isCurrentlyColliding == true)
{
Destroy(gameObject);
}
}
public void ReadyBullet(float damage, GameObject source)
{
this.damage = damage;
this.source = source;
}
}