Quantcast
Channel: Questions in topic: "error message"
Viewing all articles
Browse latest Browse all 2891

Unity operators cannot be applied to operands of type playerHealth and int

$
0
0
Im working on creating a trap in a top down 2d game, and i have a simple playerHealth script with 2 public variables the player current and max health: and a slightly bigger script for the trap. i reference the 2 variables from the playerHealth script with: public playerHealth playerMaxHP; public playerHealth playerCurrentHP; and i have the traps damage output: public int trap_Damage; but when i try to use an private void and a if statement to see if you are being damaged: ` public int playerCurrentHP; public int playerMaxHP; public playerHealth playerMaxHP; public playerHealth playerCurrentHP; private void OnTriggerEnter2D(Collider2D collison){ if (collison.tag == "Player"){ if(playerCurrentHP == playerMaxHP){ playerCurrentHP = playerMaxHP - trap_Damage; } else { playerCurrentHP = playerCurrentHP - trap_Damage; } Debug.Log("you have " + playerCurrentHP + " health!"); Destroy(gameObject); } } }` i get a error like: 'Unity operators cannot be applied to operands of type playerHealth and int'

Viewing all articles
Browse latest Browse all 2891

Trending Articles



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