Example #1
0
    public void Teleport()
    {
        // Teleport gazer
        CameraBehavior gazer = GameObject.Find("Main Camera").GetComponent <CameraBehavior>();

        //Vector3 gazerPrevPosition = GameObject.Find ("Main Camera").transform.localPosition;
        gazer.SetMostRecentTeleportPosition(transform.localPosition);
        gazer.SetShouldTeleport(true);

        // Teleport self randomly
//		Vector3 direction = Random.onUnitSphere;
//		direction.y = Mathf.Clamp(direction.y, 0.5f, 1f);
//		float distance = 2 * Random.value + 1.5f;
//		transform.localPosition = direction * distance; // transform.parent?

        // Teleport self to gazer's previous position
        // transform.localPosition = gazerPrevPosition;

        // Teleport self outside world bounds (disappear)
        transform.localPosition = new Vector3(25, 0, 0);

        // Teleport gazer avatar to gazer's previous position
        //GameObject.Find("Gazer Avatar").transform.localPosition = gazer.GetMostRecentGazePosition();

        Debug.Log("TeleportSelfAndGazer::Teleport()");
    }
Example #2
0
    public void Teleport()
    {
        // Teleport gazer
        CameraBehavior gazer = GameObject.Find("Main Camera").GetComponent <CameraBehavior>();
        //Vector3 gazerPrevPosition = GameObject.Find ("Main Camera").transform.localPosition;
        Vector3 gazerPrevPosition = gazer.transform.position;

        Debug.Log("gazerPrevPosition before: " + gazerPrevPosition);


        float distanceOffset = this.distanceThreshold;
        float distance       = (gazer.transform.position - this.transform.position).magnitude;

        if (distance < this.distanceThreshold)
        {
            if (gazerPrevPosition.x < this.transform.position.x)
            {
                gazerPrevPosition.x -= distanceOffset;
            }
            else
            {
                gazerPrevPosition.x += distanceOffset;
            }

            if (gazerPrevPosition.z < this.transform.position.z)
            {
                gazerPrevPosition.z -= distanceOffset;
            }
            else
            {
                gazerPrevPosition.z += distanceOffset;
            }
        }
        Debug.Log("gazerPrevPosition after: " + gazerPrevPosition);


        gazer.SetMostRecentTeleportPosition(gazerPrevPosition);
        //gazer.SetMostRecentAvatarPosition (gazerPrevPosition);
        gazer.SetShouldTeleport(true);

        // Teleport self outside world bounds (disappear)
        //transform.localPosition = new Vector3 (25, 0, 0);
    }