void Start() { // Added by Aislinn to get session experiment = GameObject.FindGameObjectWithTag("Experiment"); experimentGenerator = experiment.GetComponent <ExperimentGenerator>(); dotSession = experimentGenerator.session; // Added by Aislinn to get stim_start_time from DotStimScript dotStimulus = GameObject.FindGameObjectWithTag("DotStimulus"); dotStimScript = dotStimulus.GetComponent <DotStimScript>(); // Added by Aislinn to put stimulus in right location headCamera = GameObject.FindGameObjectWithTag("Camera"); transform.SetParent(headCamera.transform); stimLocList = dotSession.settings.GetIntList("stimulusLocation"); stimLoc = Quaternion.Euler(stimLocList[0], stimLocList[1], stimLocList[2]); stimDepth = dotSession.settings.GetFloat("StimDepth"); speedApertureUnits = dotSession.settings.GetInt("DotSpeed") / (2 * dotSession.settings.GetFloat("ApertureRad")); // Aperture has scaled radius of 1 here, need to scale speed to use with local position if (current_directionH == 1 && !isNoise) // "right opening" movement wedge (use for motion with leftward component) { if (!dotSession.settings.GetBool("DeterministicSignal")) { movement_angle = Quaternion.AngleAxis(-Random.Range(-current_angle / 2, current_angle / 2), Vector3.up); } transform.localRotation = Quaternion.identity * movement_angle; //Debug.Log("movement angle is " + movement_angle.eulerAngles); } if (current_directionH != 1 && !isNoise) // "left opening" movement wedge (use for motion with rightward component) { if (!dotSession.settings.GetBool("DeterministicSignal")) { movement_angle = Quaternion.AngleAxis(Random.Range(-current_angle / 2, current_angle / 2), Vector3.up); } transform.localRotation = Quaternion.identity * movement_angle; // Debug.Log("movement angle is " + movement_angle.eulerAngles); } if (isNoise && !isBuddy) { buddyDot = GameObject.Find("Dot" + buddyNumber.ToString()); float angle_degrees = Random.Range(-360, 360); movement_angle = Quaternion.AngleAxis(angle_degrees, Vector3.up); buddyDot.GetComponent <DotMotion>().movement_angle = Quaternion.AngleAxis(angle_degrees + 180, Vector3.up); transform.localRotation = Quaternion.identity * movement_angle; } if (isNoise && isBuddy) { transform.localRotation = Quaternion.identity * movement_angle; } //GetComponent<Renderer>().material.color = Random.ColorHSV(0f, 1f, 1f, 1f, 0.5f, 1f); timeSinceStartup = Time.realtimeSinceStartup; }
IEnumerator DotMotionCoroutine() { // Wait for the fixation point to dissapear yield return(new WaitForSeconds(session.settings.GetFloat("fixationTime"))); // Instantiate dot motion stimulus // set it to the location of the fixation to begin with instStim = Instantiate(stim, fixation.transform.position, Quaternion.identity); // transform.lookat may be what i need instStim.transform.Rotate(90f, 180f, 0f); instStim.SetActive(true); dotStimScript = instStim.GetComponent <DotStimScript>(); combined_direction = dotStimScript.combined_direction; // Display it for .5 seconds yield return(new WaitForSeconds(session.settings.GetFloat("stimulusTime"))); // Destroy it Destroy(instStim); stimActive = false; }