Exemplo n.º 1
0
    private void LateUpdate()
    {
        Vector3 centreExpPosition = experimentController.homeCursorController.transform.position;

        bool visible       = handCursorController.visible;
        bool isPaused      = handCursorController.isPaused;
        bool isInHomeArea  = handCursorController.isInHomeArea;
        bool taskCompleted = handCursorController.taskCompleted;
        bool isInTarget    = handCursorController.isInTarget;

        float actDist = (
            handCursor.transform.position -
            (!IsSecondaryHome ? SecondaryHomePos : centreExpPosition)
            ).magnitude;

        bool distThreshold = actDist >= MIN_DIST; //Distance cursor has moved from home position

        //Debug.Log("Actual Distance from center: " + actDist);

        //Do things when this thing is in the target (and paused), or far enough away during nocusor
        if (isPaused && !isInHomeArea)
        {
            // When IsSecondaryHome is false, target acts as a regular reach target.
            // If true, the participant must touch this "target" to spawn the real one.
            if (!IsSecondaryHome && distThreshold && !taskCompleted)
            {
                if (useExpand)
                {
                    expand = true;
                }
                else
                {
                    GetComponentInChildren <MeshRenderer>().enabled = false;
                }

                // Above only checks if its paused (for case of noCursor), needs to also check for some minimum time or distance travelled etc.
                experimentController.PauseTimer();

                experimentController.CalculateReachTime();

                targetContainerController.soundActive =
                    experimentController.GetReachTime() < 1.5f;

                targetContainerController.experimentController.positionLocCursorController.Activate();

                handCursorController.taskCompleted = true;
                handCursorController.isInTarget    = false;
            }
        }
    }
    // Update is called once per frame
    void LateUpdate()
    {
        Vector3 centreExpPosition = experimentController.homeCursorController.transform.position;

        bool visible       = handCursorController.visible;
        bool isPaused      = handCursorController.isPaused;
        bool isInHomeArea  = handCursorController.isInHomeArea;
        bool taskCompleted = handCursorController.taskCompleted;
        bool isInTarget    = handCursorController.isInTarget;

        float actDist = (
            handCursor.transform.position -
            (!IsSecondaryHome ? SecondaryHomePos : centreExpPosition)
            ).magnitude;

        bool distThreshold = actDist >= MIN_DIST; //Distance cursor has moved from home position

        //Debug.Log("Actual Distance from center: " + actDist);

        //Do things when this thing is in the target (and paused), or far enough away during nocusor
        if (isPaused && !isInHomeArea)
        {
            // When IsSecondaryHome is false, target acts as a regular reach target.
            // If true, the participant must touch this "target" to spawn the real one.
            if (!IsSecondaryHome && ((!taskCompleted && distThreshold && !visible) || isInTarget))
            {
                // Above only checks if its paused (for case of noCursor), needs to also check for some minimum time or distance travelled etc.
                //End and prepare
                experimentController.PauseTimer();

                experimentController.CalculateReachTime();

                if (experimentController.GetReachTime() < 1f)
                {
                    targetContainerController.soundActive = true;
                }
                else
                {
                    targetContainerController.soundActive = false;
                }

                //
                cursObjTracker.GetComponent <CursorObjTrackerController>().tracking = false;
                cursObjTracker.GetComponent <PositionRotationTracker>().StopRecording();

                // log target position
                experimentController.targetX = transform.position.x;
                experimentController.targetY = transform.position.y;
                experimentController.targetZ = transform.position.z;

                experimentController.EndAndPrepare();

                handCursorController.taskCompleted = true;
                handCursorController.isInTarget    = false;
            }
            else if (isInTarget)
            {
                if (RealTarget != null)
                {
                    // Fix hand cursor
                    handCursorController.isInTarget = false;

                    // Hide cursor if the type is nocursor
                    if (experimentController.session.CurrentTrial.settings.GetString("type") == "nocursor" ||
                        experimentController.session.CurrentTrial.settings.GetString("type") == "localization")
                    {
                        handCursorController.SetCursorVisibility(false);
                    }

                    handCursorController.ResetPause();

                    // Set the correct movement type for this trial
                    //handCursorController.SetMovementType(experimentController.session.CurrentTrial);

                    // set step time
                    experimentController.stepTime = Time.time;

                    cursObjTracker.GetComponent <CursorObjTrackerController>().tracking = true;
                    cursObjTracker.GetComponent <PositionRotationTracker>().StartRecording();

                    // Start timer for dings
                    experimentController.StartTimer();

                    // Re-enable the real target and disable this one
                    RealTarget.SetActive(true);
                    Destroy(gameObject);
                }
                else
                {
                    Debug.LogWarning("This isn't supposed to happen");
                }
            }
        }
    }