Beispiel #1
0
    public void Update()
    {
        if (!trackScore)
        {
            scoreboard.ManualScoreText = "Practice Round";
        }

        if (Input.GetKeyDown(KeyCode.N))
        {
            IncrementStep();
        }

        if (currentStep == 2 &&
            ctrler.CursorController.PauseTime > 0.5f &&
            ctrler.CursorController.DistanceFromHome > 0.05f &&
            trial.settings.GetString("per_block_type") == "nocursor")
        {
            IncrementStep();
        }

        if (Finished)
        {
            ctrler.EndAndPrepare();
        }

        // checks if there is a water animation in the scene
        if (d != null)
        {
            // after animation has comleted and the current step is the home step it sets the home ball to active
            if (!LeanTween.isTweening(id) && currentStep == 1)
            {
                targets[1].SetActive(true);
            }
        }
    }
    // Update is called once per frame
    void Update()
    {
        //transform.localPosition = defaultPos;

        //Calculate forward vector
        Vector3 forward = (centreEye.transform.position - new Vector3(0, 0.3f, 0)) - transform.parent.position;
        Ray     ray     = new Ray(transform.parent.position, forward);

        //Plane for intersecting

        Plane planeTOIntersect = new Plane(Vector3.down, expCentre.transform.position.y);

        //Initialise the enter variable
        float enter = 0.0f;

        if (planeTOIntersect.Raycast(ray, out enter))
        {
            //Get the point
            Vector3 hitPoint = ray.GetPoint(enter);

            //move game object to the point
            transform.position = hitPoint;

            experimentController.targetContainerController.particleSystem.transform.position = transform.position;
        }

        x = transform.localPosition.x;
        y = transform.localPosition.y;
        z = transform.localPosition.z;

        if (isLocalization)
        {
            if (OVRInput.Get(OVRInput.RawButton.RIndexTrigger, m_controller))
            {
                LogLocalization();

                //Debug.Log("Ending Localization Trial T_T bye :'(");

                targetContainerController.PlayDestroyNoise();

                experimentController.EndAndPrepare();
                handCursorController.taskCompleted = true;
                isLocalization = false;
            }

            //else if (OVRInput.Get(OVRInput.RawButton.B, m_controller))
            //{
            //    MoveCursor(0.0003f);
            //}
            //else if (OVRInput.Get(OVRInput.RawButton.A, m_controller))
            //{
            //    MoveCursor(-0.0003f);
            //}
        }
    }
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown("i"))
        {
            Debug.Log("instruction acceptor: running end and prepare");

            doneInstruction = true;

            experimentController.EndAndPrepare();
            handCursorController.taskCompleted = true;

            gameObject.SetActive(false);
        }
    }
    private void AcceptTarget(Collider other)
    {
        ExplodeParticles();
        //Debug.Log("Ding! You put the target in the box!");
        handCursorController.taskCompleted = true;
        handCursorController.ReAlignCursor();
        handCursorController.holdingItem = false;

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

        experimentController.EndAndPrepare(); //disabled for testing, enable for actual experiment use
    }
Beispiel #5
0
    // Update is called once per frame
    void Update()
    {
        switch (currentStep)
        {
        case 0:

            // mouse is inside gate 1 collider
            if (trailGate1.transform.GetChild(3).GetComponent <BoxCollider>().ClosestPoint
                    (ctrler.CursorController.MouseToPlanePoint(transform.up, car.transform.position, Camera.main)) ==
                ctrler.CursorController.MouseToPlanePoint(transform.up, car.transform.position, Camera.main))
            {
                IncrementStep();
            }

            // mouse gets near car
            if ((ctrler.CursorController.MouseToPlanePoint(transform.up, car.transform.position, Camera.main) - car.transform.position).magnitude < 0.15f)
            {
                //IncrementStep();
            }
            break;

        case 1:

            foreach (BaseTarget t in midwayTriggers)
            {
                // if the car hits the midway trigger, it is going the correct way
                if (t.Collided)
                {
                    carPastMidpoint = true;
                }
            }


            // if the car hits the start gate trigger, it is not going the right way
            if (startCollider.GetComponent <BaseTarget>().Collided)
            {
                carPastMidpoint = false;
            }

            // car position = mouse position
            car.transform.position = ctrler.CursorController.MouseToPlanePoint(transform.up, car.transform.position, Camera.main);

            if (isOnTrack)
            {
                inTrackTime += Time.deltaTime;
            }
            else
            {
                outTrackTime += Time.deltaTime;
            }

            break;

        case 2:
            IncrementStep();
            break;
        }

        if (Finished)
        {
            ctrler.EndAndPrepare();
        }
    }
Beispiel #6
0
 void End()
 {
     ctrler.EndAndPrepare();
 }
Beispiel #7
0
    public void LateUpdate()
    {
        ExperimentController ctrler = ExperimentController.Instance();

        switch (currentStep)
        {
        // When the user holds their hand and they are outside the home, begin the next phase of localization
        case 2 when ctrler.CursorController.PauseTime > 0.5f &&
            ctrler.CursorController.DistanceFromHome > 0.03f:
            IncrementStep();
            break;

        case 3:
            // VR: User uses their head to localize their hand
            // Non-VR: User uses horizontal axis to localize their mouse

            if (ctrler.Session.settings.GetString("experiment_mode") == "target")     // if in vr
            {
                // raycasts from camera to set localizer position
                Plane plane = new Plane(Vector3.down, ctrler.transform.position.y);
                Ray   r     = new Ray(Camera.main.transform.position, Camera.main.transform.forward);

                if (plane.Raycast(r, out float hit))
                {
                    localizer.transform.position = r.GetPoint(hit);
                }
            }
            else
            {
                // A/D keys, left/right arrow keys, or gamepad joystick as input
                LocalizerAngle2D += Input.GetAxisRaw("Horizontal") * localizerSpeed2D;
                LocalizerAngle2D  = Mathf.Clamp(LocalizerAngle2D, -90f, 90f);

                float angle = LocalizerAngle2D * Mathf.Deg2Rad;

                // centre == centre of Arc == centre of Home
                Vector3 centre = Target.transform.position;

                // distance from home: copied from ArcTarget script, multiplied by the size of the arc
                float distance = (Target.GetComponent <ArcScript>().TargetDistance + centre.z) * Target.transform.localScale.x;

                // find position along arc
                Vector3 newPos = new Vector3(Mathf.Sin(angle), 0, Mathf.Cos(angle)) * distance;
                newPos += centre;

                localizer.transform.position = newPos;
            }

            // switch from click to enter or something? issue with clicking to refocus window

            // If the user presses the trigger associated with the hand, we end the trial
            if (ctrler.CursorController.IsTriggerDown(ctrler.CursorController.CurrentTaskHand) || Input.GetKeyDown(KeyCode.N) || Input.GetKeyDown(KeyCode.Space))
            {
                IncrementStep();
            }

            break;
        }

        if (Finished)
        {
            ctrler.EndAndPrepare();
        }
    }
    // 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");
                }
            }
        }
    }