Question by
SamuraiFaith · Sep 06, 2020 at 01:31 AM ·
tagging
Can not detect Tag
I have also tried making a samll overlap area around the 2D collider but that didn't work out here is the script`
using UnityEngine; using System.Collections;
public class hELT : MonoBehaviour { public int currentHealth = 5; public int maxHealth = 5;
void Start() {
}
void Update() {
if (currentHealth > maxHealth) {
currentHealth = maxHealth;
}
if (currentHealth <= 0) {
currentHealth = 0;
Die();
}
}
void Die() {
Destroy(gameObject);
}
void TakeDamage(int damage)
{
currentHealth -= damage;
}
void OnColliderEnter(Collider other)
{
if (other.tag == "Enemy")
{
TakeDamage(5);
}
}
}
`
Comment
OnCollisionEnter(Collision col) {} not OnColliderEnter... Is that a 2D Game you are creating?
Yes indeed it is, i have tried out the script and it still isnt working..
if this effects anything, the player Rigidbody (the one on who the script is on) has1 boxcolliders and 1 round collider
Can you post the updated script? This was the issue for sure, but I need to see, if you have done everything correctly.