void OnTriggerEnter2D(Collider2D other) // if the collider got trigger by player not other { if (other.name == "Player") { GetComponent <Animator>().SetTrigger("axe"); Healthmanager.Hurtplayer(damageToGive); } }
private void OnTriggerEnter2D(Collider2D other) { if (other.GetComponent <Player>() == null) { return; } Healthmanager.Hurtplayer(-HealthToGive); //Pickupsound.Play(); Destroy(gameObject); }
public Healthmanager healthManager; // so the player doesnt die every time his hp is 0, from healthmanager // Use this for initialization void Start() { player = FindObjectOfType <Player>(); healthManager = FindObjectOfType <Healthmanager>(); }