Quantcast
Channel: Questions in topic: "enemy"
Viewing all articles
Browse latest Browse all 1488

Enemy's health wont get set from different script.

$
0
0
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.

Viewing all articles
Browse latest Browse all 1488

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>