I'm trying to access the health variable from an EnemyMovement class and apply damage/subtract from that health through a different class.
using UnityEngine;
using System.Collections;
public class hitMarker
: MonoBehaviour {
public EnemyMovement enemyMovement;
int enemyHealth;
void Start(){
enemyHealth = enemyMovement.health;
}
void OnCollisionEnter2D(Collision2D collision){
if (collision.gameObject.tag == "enemy") {
//Debug.Log ("hit");
enemyHealth -= DonnyMovement.damageKick;
enemyMovement.health = enemyHealth;
}
}
}
I believe my problem is the health variable isn't getting set to the new damage version of it.
↧