Ejemplo n.º 1
0
    void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.tag == "Player")
        {
            CharacterController controller = other.gameObject.GetComponent <CharacterController>();
            UnityStandardAssets.Characters.FirstPerson.FirstPersonController player_script = (UnityStandardAssets.Characters.FirstPerson.FirstPersonController)other.gameObject.GetComponent("FirstPersonController");
            if (controller != null)
            {
                controller.enabled = false;
            }

            other.gameObject.transform.position = teleport_to.transform.position;
            other.gameObject.transform.rotation = teleport_to.transform.rotation;


            if (controller != null)
            {
                controller.enabled = true;
            }
            if (player_script != null)
            {
                player_script.Reset();
            }
        }
    }
Ejemplo n.º 2
0
    IEnumerator Respawn()
    {
        CharacterController controller = player_inside.GetComponent <CharacterController>();

        UnityStandardAssets.Characters.FirstPerson.FirstPersonController player_script = (UnityStandardAssets.Characters.FirstPerson.FirstPersonController)player_inside.GetComponent("FirstPersonController");


        if (controller != null)
        {
            controller.enabled = false;
        }
        if (player_script != null)
        {
            player_script.enabled = false;
        }
        // loop over 1 second backwards
        for (float i = 0; i < 1; i += Time.deltaTime)
        {
            // set color with i as alpha
            img.color = new Color(1, 1, 1, i);
            player_inside.transform.Rotate(0, 0, Time.deltaTime * 90);
            yield return(null);
        }


        player_inside.transform.position = die_teleport_target.transform.position;
        player_inside.transform.rotation = die_teleport_target.transform.rotation;

        yield return(null);

        // loop over 1 second
        for (float i = 0; i <= 1; i += Time.deltaTime)
        {
            // set color with i as alpha
            img.color = new Color(1, 1, 1, 1 - i);
            yield return(null);
        }

        img.color = new Color(1, 1, 1, 0);
        if (controller != null)
        {
            controller.enabled = true;
        }
        if (player_script != null)
        {
            player_script.enabled = true; player_script.Reset();
        }
        respawn_finished = true;
        yield break;
    }