Exemple #1
0
    IEnumerator OpenGate()
    {
        GetComponentInChildren <Light>().color = Color.green;
        ThirdPersonCharacter p = GameObject.FindGameObjectWithTag("Player").GetComponent <ThirdPersonCharacter>();

        yield return(new WaitForSeconds(1.0f));

        //Delete everything above this if no animation for button

        if (doorAnim)
        {
            doorAnim.SetBool("Open", true);
        }
        p.enabled  = false;
        camParent  = Camera.main.transform.parent;
        prevCamPos = Camera.main.transform.localPosition;
        prevCamRot = Camera.main.transform.localRotation;
        Camera.main.transform.parent        = gate.transform;
        Camera.main.transform.localPosition = new Vector3(0, 3, 2);
        Camera.main.transform.localRotation = Quaternion.LookRotation(gate.transform.position - Camera.main.transform.position);

        foreach (Collider c in gate.GetComponents <Collider> ())
        {
            c.enabled = false;
        }

        yield return(new WaitForSeconds(2));

        p.enabled = true;
        Camera.main.transform.parent        = camParent;
        Camera.main.transform.localPosition = prevCamPos;
        Camera.main.transform.localRotation = prevCamRot;
    }