using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Bullet : MonoBehaviour
{
public float damageTaken;
// Update is called once per frame
void Update()
{
Debug.Log(damageTaken);
}
private void Start()
{
}
private void OnCollisionEnter2D(Collision2D collision)
{
if(collision.transform.tag == "Enemy")
{
Destroy(gameObject);
damageTaken += 1;
Debug.Log("hit enemy");
}
}
}
when the collision enter , the debug.log(“hit enemy”) executes but the damage taken doesnt +1 and constantly stay at 0.