Esempio n. 1
0
    private IEnumerator Rush()
    {
        float progress  = 0;
        float increment = smoothness / duration;

        Eye.GetComponent <MeshRenderer>().material.SetColor("_Color", Color.red);
        Legs1.GetComponent <MeshRenderer>().material.SetColor("_Color", Color.red);
        Legs2.GetComponent <MeshRenderer>().material.SetColor("_Color", Color.red);


        stopwalking = true;
        GetComponent <UnityEngine.AI.NavMeshAgent>().enabled = false;
        yield return(new WaitForSeconds(whaiting));

        rushing = true;
        anim.Play("Rush");
        yield return(new WaitForSeconds(rushingtime));

        rushing = false;
        yield return(new WaitForSeconds(1.0f));

        stopwalking = false;
        if (!bStuck)
        {
            GetComponent <UnityEngine.AI.NavMeshAgent>().enabled = true;
        }

        Eye.GetComponent <MeshRenderer>().material.SetColor("_Color", Color.green);
        Legs1.GetComponent <MeshRenderer>().material.SetColor("_Color", Color.green);
        Legs2.GetComponent <MeshRenderer>().material.SetColor("_Color", Color.green);
    }
Esempio n. 2
0
    void Start()
    {
        anim        = this.gameObject.GetComponent <Animator>();
        Eye         = this.gameObject.transform.Find("Sphere_001").gameObject;
        Legs1       = this.gameObject.transform.Find("Cylinder_004").gameObject;
        Legs2       = this.gameObject.transform.Find("Cylinder_005").gameObject;
        Target      = GameObject.Find("Robo-Mainchar");
        bStuck      = false;
        stopwalking = false;
        rushing     = false;
        speed       = 0f;

        ToLookAt = new Vector3(Target.transform.position.x, this.transform.position.y, Target.transform.position.z);
        this.transform.LookAt(ToLookAt);

        Eye.GetComponent <MeshRenderer>().material.SetColor("_Color", Color.green);
        Legs1.GetComponent <MeshRenderer>().material.SetColor("_Color", Color.green);
        Legs2.GetComponent <MeshRenderer>().material.SetColor("_Color", Color.green);
    }