Exemplo n.º 1
0
 void OnTriggerStay2D(Collider2D other)
 {
     SarahController controller = other.GetComponent<SarahController >();
     if (controller != null)
     {
         controller.ChangeHealth(-1); // Damage on stepping on spikes
     }
 }
Exemplo n.º 2
0
    void OnCollisionEnter2D(Collision2D other) // Check for collision
    {
        SarahController player = other.gameObject.GetComponent <SarahController>();

        if (player != null)
        {
            player.ChangeHealth(-1); //Change Player Health
        }
    }
Exemplo n.º 3
0
    void OnTriggerEnter2D(Collider2D other)
    {
        SarahController controller = other.GetComponent <SarahController>();

        if (controller != null)
        {
            if (controller.health < controller.maxHealth)
            {
                controller.ChangeHealth(1); // Add Health on eating berry
                Destroy(gameObject);
            }
        }
    }