コード例 #1
0
    void OnTriggerStay2D(Collider2D other)
    {
        GG_moving ggController = other.GetComponent <GG_moving>();

        if (ggController != null)
        {
            ggController.ChangeHealth(-1);
        }
    }
コード例 #2
0
    void OnTriggerEnter2D(Collider2D other)
    {
        GG_moving ggController = other.GetComponent <GG_moving>();

        if (ggController != null && ggController.currentHealth < ggController.maxHealth)
        {
            ggController.ChangeHealth(1);
            Destroy(gameObject);
        }
    }