I can’t understand why my code isn’t working. I used this the other day for an hour and it worked perfectly. Then suddenly it just stopped working!
The float values will not subtract whatsoever. The collision is working, and the tag system as well.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnemyHealthSystem : MonoBehaviour
{
public float HP = 100;
public float PistolDamage = 5;
public GameObject DestroyMe;
void Damager (float amount)
{
HP -= amount;
Debug.Log ("amount" + amount);
}
void OnCollisionEnter (Collision col)
{
if (col.gameObject.tag == (" PistolAmmo "))
Damager (PistolDamage);
{
Debug.Log ("HP"+ HP);
}
}
void Update()
{
if (HP <= 0)
Destroy (DestroyMe);
}
}