Ejemplo n.º 1
0
    void Update()
    {
        CameraBehavior gazer = GameObject.Find("Main Camera").GetComponent <CameraBehavior>();

        // Update rotation and gazed frame count
        if (!gazer.GetIsDisembodied())
        {
            Quaternion lookRot = Quaternion.LookRotation(gazer.transform.forward);              // Face same direction as camera

            // Update how long we've been gazed at
            if (this.isGazedAt)
            {
                this.framesGazedAt++;
            }
            else
            {
                lookRot = Quaternion.LookRotation(new Vector3(0, 0, 0));                  // Face towards center (or rather, original)
            }

            // Adjust rotation by lerping
            this.transform.rotation = Quaternion.Lerp(this.transform.rotation, lookRot, 0.05f);

            //Debug.Log ("framesGAzedAt: " + this.framesGazedAt);
        }

        // Adjust dimensions based on gazed time
        transform.localScale = ((float)this.framesGazedAt / this.framesGazedAtThreshold) * (this.scaleFactor * this.startingScale) + this.startingScale;

        // Teleport if we're over the gazed threshold
        if (this.framesGazedAt >= this.framesGazedAtThreshold)
        {
            Teleport();
        }
    }
    // Update is called once per frame
    void Update()
    {
        GameObject     mainCamera     = GameObject.Find("Main Camera");
        CameraBehavior cameraBehavior = mainCamera.GetComponent <CameraBehavior> ();
        //int gazeIdx = cameraBehavior.GetMostRecentGazeIndex();
        int gazeFrames = 0;
        int teleportationFramesThreshold = 120;

        // TODO: Fix this so that the tail of the fragment doesn't get cut off
        //if (cameraBehavior.GetIsDisembodied()) {
        //	return;
        //}

        // Query the number of frames gazed at, then set our emitter's parameter
        if (entityIdx < 0)           // Eve (Gazer)
        {
            gazeFrames = GameObject.Find("Gazer Avatar").GetComponent <GazerAvatarGazeBehavior>().GetFramesGazedAt();
            if (!cameraBehavior.GetIsDisembodied() && cameraBehavior.GetFramesSinceLastTeleportation() < teleportationFramesThreshold)
            {
                return;
            }
        }
        else           // Everyone else
        {
            Transform gazeEntity = GameObject.Find("Entity Manager").GetComponent <GameBehavior> ().GetEntity(this.entityIdx);
            gazeFrames = gazeEntity.GetComponent <TeleportSelfAndGazer> ().GetFramesGazedAt();
        }
        this.GetComponent <FMODUnity.StudioEventEmitter> ().SetParameter("framesGazedAt", gazeFrames);
    }
Ejemplo n.º 3
0
    // Update is called once per frame
    void Update()
    {
        GameObject     mainCamera             = GameObject.Find("Main Camera");
        CameraBehavior cameraBehavior         = mainCamera.GetComponent <CameraBehavior> ();
        float          rotationOffset         = Mathf.Abs(mainCamera.transform.eulerAngles.y / 360);
        float          timeSinceTeleportation = Mathf.Min(cameraBehavior.GetFramesSinceLastTeleportation() / framesSinceLastTeleportationThreshold, 1.0f);
        //float gazeAmount = cameraBehavior.GetGazeAmount ();
        float isDisembodiedFloat = cameraBehavior.GetIsDisembodied() ? 1.0f : 0.0f;
        float characterIndex     = (cameraBehavior.GetIsDisembodied() ? cameraBehavior.GetMostRecentGazeIndex() : -1.0f) // Either character at most recent gazed index, or Eve character itself
                                   + 1.01f;                                                                              // Offset since Eve is 0.0-1.0

        // For GazerAmbience
        //emitter.SetParameter ("Rotation Offset", rotationOffset);
        //emitter.SetParameter ("Time Since Teleportation", timeSinceTeleportation);
        //emitter.SetParameter ("Is Disembodied?", isDisembodiedFloat);

        // For AllCharactersMain
        emitter.SetParameter("timeSinceTeleportation", timeSinceTeleportation);
        emitter.SetParameter("characterIndex", characterIndex);

        //Debug.Log ("time since teleportation: " + timeSinceTeleportation + ", character idx: " + characterIndex);
    }
Ejemplo n.º 4
0
    /// Called when the user is looking on a GameObject with this script,
    /// as long as it is set to an appropriate layer (see GvrGaze).
    public void OnGazeEnter()
    {
        CameraBehavior gazer = GameObject.Find("Main Camera").GetComponent <CameraBehavior>();

        if (!gazer.GetIsDisembodied())
        {
            SetGazedAt(true);
        }
        else
        {
            SetIsAboutToConverse(true);
        }
        Debug.Log("gzze enger: " + this.isAboutToConverse);
    }
Ejemplo n.º 5
0
    // Update is called once per frame
    void Update()
    {
        CameraBehavior cameraBehavior = mainCamera.GetComponent <CameraBehavior> ();

        // Set camera's isGazing by querying entities
        int cameraIsGazingAt            = -1;
        int cameraIsAboutToConverseWith = -1;

        for (int i = 0; i < this.entities.Length; i++)
        {
            Transform entity = this.entities [i];

            if (cameraBehavior.GetIsDisembodied())
            {
                // Set camera's most recent converser
                entity.GetComponent <TargetWatcherBehavior> ().SetBypass(false);
                bool isAboutToConverse = entity.GetComponent <TeleportSelfAndGazer> ().GetIsAboutToConverse();
                if (isAboutToConverse)
                {
                    cameraIsAboutToConverseWith = i;
                }
            }
            else
            {
                // Set camera's most recent gazed at entity
                entity.GetComponent <TargetWatcherBehavior> ().SetBypass(true);
                bool isGazedAt = entity.GetComponent <TeleportSelfAndGazer> ().GetIsGazedAt();
                if (isGazedAt)
                {
                    cameraIsGazingAt = i;
                    // break;
                }

                // Reset position if out of bounds
                // TODO: Track down the root cause of this bug; probably to do with conflicting teleport/gaze settings
                if (!this.PositionIsInWorldBoundaries(entity.position))
                {
                    entity.GetComponent <TeleportSelfAndGazer> ().Reset();
                }
            }
        }
        cameraBehavior.SetIsGazingAt(cameraIsGazingAt);
        cameraBehavior.SetIsAboutToConverseWith(cameraIsAboutToConverseWith);
    }
Ejemplo n.º 6
0
    // Update is called once per frame
    void Update()
    {
        CameraBehavior gazer = GameObject.Find("Main Camera").GetComponent <CameraBehavior>();

        // Update how long we've been gazed at
        if (this.isGazedAt && gazer.GetIsDisembodied())
        {
            this.framesGazedAt++;
            Debug.Log("framesGAzedAt: " + this.framesGazedAt);
        }

        // Adjust dimensions based on gazed time
        //transform.localScale = ((float) this.framesGazedAt / this.framesGazedAtThreshold) * (scaleFactor * this.startingScale) + this.startingScale;

        // Calculate distance from player (camera)
        float distance = (gazer.transform.position - this.transform.position).magnitude;

        // Teleport if we're over the gazed threshold or under the distance threshold
        if (this.framesGazedAt >= this.framesGazedAtThreshold || distance < distanceThreshold)
        {
            Teleport();
        }
    }