//START A TRIAL!
    //call this next one on the "On Trial Begin" event
    public void StartReachTrial(Trial trial)
    {
        //Debug.Log("starting reach trial!");
        trialInBlock = trial.numberInBlock;

        // set isInstruction trial to true when you need to wait for instruction
        if (trial.numberInBlock == 1 && Convert.ToBoolean(trial.settings["show_instruction"]))
        {
            isInstructionTrial = true;
        }
        else
        {
            isInstructionTrial = false;
        }

        // Show instructions when required
        // If the trial is the first trial in the block
        if (trial.numberInBlock == 1)
        {
            //Set the instruction text to instruction_text
            instructionTextMesh.text = Convert.ToString(trial.settings["instruction_text"]);

            // If showInstruction is true
            if (Convert.ToBoolean(trial.settings["show_instruction"]) == true)
            {
                isDoneInstruction = false;
                Debug.Log("show instruction = true,  expanding");

                // transition to the big instruction, change the text
                instructionController.ExpandInstruction();
                instructionController.IsStill();
            }

            else if (Convert.ToBoolean(trial.settings["show_instruction"]) == false)
            {
                Debug.Log("show instruction = false,  doing nothing");
                isDoneInstruction = true;
            }
        }

        //Pseudorandom target location
        if (shuffledTargetList.Count < 1)
        {
            if (Convert.ToInt32(trial.settings["target_list_to_use"]) == 1)
            {
                shuffledTargetList = new List <int>(targetList_1);
            }
            else if (Convert.ToInt32(trial.settings["target_list_to_use"]) == 2)
            {
                shuffledTargetList = new List <int>(targetList_2);
            }
            shuffledTargetList.Shuffle();
        }

        int targetLocation = shuffledTargetList[0];

        //print(targetLocation);
        //remove the used target from the list
        shuffledTargetList.RemoveAt(0);

        //determine Target Position (used by ColliderDetector to instantiate the target)
        //rotate the target holder (the -90 just needs to be done for some reason..)
        // here we are casting to a float (explicit conversion)
        targetYOffset = (float)Convert.ToDouble(trial.settings["target_y_offset"]) * -1;

        // Debug.LogFormat("targetYOffset in Controller set to {0}", targetYOffset);

        targetHolder.transform.rotation = Quaternion.Euler(targetYOffset, targetLocation - 90, 0);

        //check for clamped or no cursor
        if (Convert.ToString(trial.settings["trial_type"]).Contains("clamped"))
        {
            handCursorObject.SetActive(false);

            clampedHandCursorObject.SetActive(true);
            //clampedHandCursorObject.GetComponent<MeshRenderer>().enabled = false;
            //print("setting clamped to active");
        }
        else if (Convert.ToString(trial.settings["trial_type"]).Contains("no_cursor"))
        {
            // for no_cursor: The object has to be active (for collisions), but not visible (meshrenderer)
            handCursorObject.SetActive(true);
            handCursorObject.GetComponent <MeshRenderer>().enabled = false;
            clampedHandCursorObject.SetActive(false);
            //print("setting clamped to inactive");
        }
        else
        {
            handCursorObject.SetActive(true);
            handCursorObject.GetComponent <MeshRenderer>().enabled = true;
            clampedHandCursorObject.SetActive(false);
            //print("setting clamped to inactive");
        }

        //set the rotation for this trial

        // first check if this is a gradual rotation block
        if (Convert.ToBoolean(trial.settings["is_gradual"]) && trial.numberInBlock <= Math.Abs((Convert.ToSingle(trial.settings["rotation"]))))
        {
            // add gradualStep if positive, subtract if negative
            rotationAngle = (trial.numberInBlock - 1) * gradualStep * Math.Sign(Convert.ToSingle(trial.settings["rotation"]));
        }
        else
        {
            rotationAngle = Convert.ToSingle(trial.settings["rotation"]);
        }

        // set the rotation for the trial
        rotatorObject.transform.rotation = Quaternion.Euler(0, rotationAngle, 0);
        Debug.Log(rotationAngle);

        // explicitly convert settings["visible_cursor"] to a boolean for if statement
        // this is just to save in the trial by trial csv
        bool visibleCursor = Convert.ToBoolean(trial.settings["visible_cursor"]);

        trialType = Convert.ToString(trial.settings["trial_type"]);

        //Debug.LogFormat("the cursor is {0}", trialType);

        // only tilt the plane on the first trial of block
        if (trial.numberInBlock == 1)
        {
            // change plane settings for this trial
            if (Convert.ToString(trial.settings["plane_settings"]).Contains("tilt_on_x"))
            {
                StartCoroutine(planeController.SetToTiltOnX());
            }
            else if (Convert.ToString(trial.settings["plane_settings"]).Contains("tilt_on_z"))
            {
                StartCoroutine(planeController.SetToTiltOnZ());
            }
            else if (Convert.ToString(trial.settings["plane_settings"]).Contains("flat"))
            {
                planeController.SetToFlat();
            }
            else
            {
                planeController.SetToNone();
            }
        }

        //add these things to the trial_results csv (per trial)
        trial.result["trial_type"]        = trial.settings["trial_type"];
        trial.result["cursor_visibility"] = trial.settings["visible_cursor"];
        trial.result["rotation"]          = rotationAngle;
        trial.result["target_angle"]      = targetLocation;

        //Create homeposition
        homePositionObject.SetActive(true);

        // turn off returnHelper
        returnHelper.SetActive(false);
    }