示例#1
0
    public void Teleport(GameObject player, Teleportal portal)
    {
        portal.playerIsComing = true;

        Smaterializator smat = player.GetComponent <Smaterializator>();

        if (smat == null)
        {
            player.GetComponent <Rigidbody>().velocity = Vector3.zero;
            player.transform.position = portal.transform.position;
        }
        else
        {
            StartCoroutine(ChagePositionAfterSmaterialization(player, smat, portal));
        }
    }
示例#2
0
    IEnumerator ChagePositionAfterSmaterialization(GameObject player, Smaterializator smat, Teleportal portal)
    {
        //Graphic Effect
        var emission = particle.emission;
        var vel      = particle.velocityOverLifetime;

        foreach (MeshRenderer rend in cones)
        {
            rend.material = ActivePortalDirectionMat;
        }
        emission.rateOverTime = 15;
        vel.y = downward ? -30 : 30;

        smat.FadeOut();



        while (smat.isFading)
        {
            yield return(0);
        }



        //Revert Graphic Effect
        foreach (MeshRenderer rend in cones)
        {
            rend.material = defaultMat;
        }
        emission.rateOverTime = 2;
        vel.y = downward ? -3 : 3;

        smat.FadeIn();

        //Logic
        player.GetComponent <Rigidbody>().velocity = Vector3.zero;
        player.transform.position = portal.transform.position;
    }