Exemple #1
0
    //Responsibilities:
    /// <summary>
    /// This script's bgi responsibility is shooting out a ray from the players gaze (ie the forward direction of the normal)
    /// and seeing if it hits an object of type Animal_LP and if so, which animal it is...
    /// </summary>

    void Awake()
    {
        if (Instance == null)
        {
            Instance = this;
        }
        else
        {
            Destroy(Instance);
        }
    }
Exemple #2
0
    // Update is called once per frame
    void Update()
    {
        if (TobiiAPI.IsConnected)
        {
            hasFocus = _gazeAware.HasGazeFocus;
        }
        else
        {
            RaycastHit hit = PlayerGaze.FindPlayerGaze(playerCam, false);
            hasFocus = hit.collider == _collider;
        }


        var distBool = false;

        // This object is gazed upon
        if (hasFocus)
        {
            distBool = Vector3.Distance(transform.position, playerTrans.position) < AwarenessDistance;
            if (distBool)
            {
                _cumulativeTimer += Time.deltaTime;
                stillLookedAtEvent.Invoke();
            }
        }

        // This object has just started being gazed upon
        if (hasFocus && !_stillLookedAt)
        {
            if (distBool)
            {
                _stillLookedAt = true;
                lookedAtEvent.Invoke();
            }
        }

        // This object is no longer being gazed upon
        if (_stillLookedAt && !hasFocus)
        {
            _stillLookedAt = false;
            UpdateLoggingValues();
            notLookedAtEvent.Invoke();
        }

        if (debugMode)
        {
            debugCumulativeTime = RetrieveCumulativeTimer();
        }
    }
Exemple #3
0
    // ------------- Update -----------------
    void Update()
    {
        if (_disable)
        {
            currentLookAt = LookTypes.idle;
        }

        switch (currentLookAt) // Checks which type of gaze the light should use
        {
        case LookTypes.followGaze:
            // Look at gaze
            varyAmount = varyAmountFollowGaze;
            innerAngle = standardInnerAngle;
            outerAngle = standardOuterAngle;
            turnTime   = resetTurnTime;
            pos        = PlayerGaze.FindPlayerGaze();
            pos        = DecideTargetGaze(pos);
            break;

        case LookTypes.stareAtGaze:
            // Stare at gaze (No / less saccades)
            varyAmount = varyAmountStareAtGaze;
            innerAngle = focusedInnerAngle;
            outerAngle = focusedOuterAngle;
            turnTime   = resetTurnTime;
            pos        = PlayerGaze.FindPlayerGaze();
            pos        = DecideTargetGaze(pos);
            break;

        case LookTypes.idle:
            // Idle
            varyAmount = varyAmountIdle;
            innerAngle = unfocusedInnerAngle;
            outerAngle = unfocusedOuterAngle;
            turnTime   = idleTurnTime;
            pos        = DecideIdlePoint();
            break;

        case LookTypes.stareAtObject:
            // Look at object
            varyAmount = varyAmountStareAtObject;
            innerAngle = focusedInnerAngle;
            outerAngle = focusedOuterAngle;
            turnTime   = resetTurnTime;
            pos        = currentObject.position;
            break;

        case LookTypes.distractingGaze:
            // Stare at spot in player FoV furthest from the bookshelf to distract them
            if (altGazeActive)     // Note: Might cause problems by causing the lights to use old information.
            {
                break;
            }
            varyAmount    = varyAmountStareAtObject;
            innerAngle    = focusedInnerAngle;
            outerAngle    = focusedOuterAngle;
            turnTime      = resetTurnTime;
            pos           = DecideDistractionPoint();
            distracting   = true;
            altLookTimer  = Time.time;
            altGazeActive = true;
            break;

        case LookTypes.alternateObjects:
            // Look at bookshelf and books alternatingly
            varyAmount = varyAmountStareAtObject;
            innerAngle = standardInnerAngle;
            outerAngle = standardOuterAngle;
            turnTime   = resetTurnTime;
            pos        = DecideObjectAlternateing(pos);
            break;

        case LookTypes.lookAtPlayer:
            // Look at the player character
            mainTimer  = 0;
            varyAmount = varyAmountStareAtObject;
            innerAngle = focusedInnerAngle;
            outerAngle = focusedOuterAngle;
            turnTime   = resetTurnTime;
            pos        = PlayerCharacter.position;
            if (!altGazeActive)
            {
                altLookTimer = Time.time;
            }
            altGazeActive = true;
            break;

        default:
            pos = PlayerGaze.FindPlayerGaze();
            break;
        }

        // Select target. Rotate to it. Saccade around it.
        if (Time.time - mainTimer > lastMoveTime && !moving)
        {
            CalcDoRotation(pos);
            // Resets the gaze mode/type
            if (Time.time - altLookTimer > altContinueTime && altGazeActive)
            {
                altGazeActive = false;
                altLookTimer  = 0;
                currentLookAt = resetLookAt;
            }
        }

        var position = thisTrans.position;

        Debug.DrawRay(position, pos - position,
                      Color.yellow);
    }