Whenever I go back into Unity I get the error:
Assets\Bullet.cs(14,13): error CS0120: An object reference is required for the non-static field, method, or property ‘enemyHP.takeDamageEnemy(int)’
enemyHP.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class enemyHP : MonoBehaviour
{
public int curEnemyHP = 100;
public int maxEnemyHP = 100;
void Start()
{
curEnemyHP = maxEnemyHP;
}
public void takeDamageEnemy(int damage) {
curEnemyHP -= damage;
if (curEnemyHP <= 0) {
Destroy(gameObject);
}
}
}
Bullet.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Bullet : MonoBehaviour
{
void OnCollisionEnter2D(Collision2D collision) {
Destroy(gameObject);
}
void OnTriggerEnter2D(Collider2D other) {
if (other.gameObject.tag == "enemy") {
enemyHP.takeDamageEnemy(20);
}
}
}