Example #1
0
    //Public because we want to call it from elsewhere like the projectile script
    public void Fix()
    {
        broken = false;
        rigidbody2D.simulated = false;
        animator.SetTrigger("Fixed");

//-----Particle effect -------
        Instantiate(fixedEffect, rigidbody2D.position, Quaternion.identity);

        smokeEffect.Stop();
        audioSource.PlayOneShot(fixSound);
        textBox.SetActive(true);

//------------------------- working

        GameObject rubyControllerObject = GameObject.FindWithTag("RubyController"); //this line of code finds the RubyController script by looking for a "RubyController" tag on Ruby

        if (rubyControllerObject != null)

        {
            rubyController = rubyControllerObject.GetComponent <RubyController>();
            rubyController.ChangeRobot(1);

            print("Found the RubyConroller Script!");
        }
    }