Search Unity

fruit supplies, bug? I need help Ruby 2DKIT

Discussion in '2D' started by LuizFernando02, Jul 15, 2019.

  1. LuizFernando02

    LuizFernando02

    Joined:
    Jul 13, 2019
    Posts:
    1
    Hi everyone, I'm having a question, I'm doing a tutorial "Ruby Adventure 2D KIT" so far I did not have problems to do the programming and the settings on the unit, anyway .. I realized that the fruits that give life to Ruby goes exactly when I I get 4 fruits, there's more in the scene, I have the programming and there's nothing limit or something, someone has some idea of this bug.
    Note: this occurs when I make a specific path if I change the route of picking the fruit, this does not happen .. :(
    Thank you in advance!

    Programming of life fruit


    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;

    public class HealthCollectible : MonoBehaviour
    {

    void OnTriggerEnter2D(Collider2D other)
    {
    RubyController controller = other.GetComponent<RubyController>();


    if (controller != null)
    {
    if (controller.health < controller.maxHealth)
    {

    controller.ChangeHealth(1);
    Destroy(gameObject);
    }
    }
    }
    }