![]() ![]() options = False import ctypes GL = pyglet. # Shaders will work but require OpenGL2.0 drivers AND PyOpenG元.0 import pyglet pyglet. # Ensure setting pyglet.options to False is done prior to any # other calls to pyglet or pyglet submodules, otherwise it may not get picked # up by the pyglet GL engine and have no effect. # Provide a visible wrapper function to refresh all the dot locations so that # the whole field can be more easily refreshed between trials. # Update the dot direction immediately for 'walk' as otherwise when the # coherence varies some signal dots will inherit the random directions of # previous walking dots. This stops the concentration of dots at # one side of field when lifetime is long. # Replaces out of bounds but still live dots at opposite edge of aperture # instead of randomly within the field. # Distributed under the terms of the GNU General Public License (GPL). """ # Part of the PsychoPy library # Copyright (C) 2002-2018 Jonathan Peirce (C) 2019-2022 Open Science Tools Ltd. #myfile2.#!/usr/bin/env python # -*- coding: utf-8 -*- """This stimulus class defines a field of dots with an update rule that determines how they change on every call to the. #myfile2.write(str(probe1) '< timing of probe1 (on which count)' '\n') #myfile2.write(str(ISIshock) '< IF ISI shock, then shock at this seconds' '\n') #myfile2.write(str(whenShock) '< either a number or zero, if NOT number then shock in ISI' '\n') #myfile2.write(str(thisISI) '< length of ISI' '\n') #myfile2.write(str(whichTrialProbe) '< whether probes or not' '\n') ![]() ![]() #myfile2.write(str(COND_LIST) '< this condition' '\n') #print (str(ISIshock) '<< IF above is 0, then ISI shock is at.') #print (str(whenShock) '<< WHEN SHOCK, if this is 0, then shock in ISI') #print (str(thisISI) '<< LENGTH OF ISI in seconds') #print (str(whichTrialProbe) '<< if 0, then no probes delivered this trial') #print (str(COND_LIST) '<< THIS CONDITION') Instructions.text= 'PUT SOMETHING HERE, PRESS SPACE TO BEGIN \n this is now a new line \n and now this is' Main_directory= 'C:\\Users\\eegadmin\\Desktop\\SHOCK\\' White_noise = sound.Sound('C:\\Users\\eegadmin\\Desktop\\SUMICH_SHOCK\\bang.wav') Instructions=visual.TextStim(myWin, text='', pos=,color=,height=30,wrapWidth=1500) ThisCond=visual.TextStim(myWin, text='A', pos=,color=,height=30,wrapWidth=1500) ThisText=visual.TextStim(myWin, text='A', pos=,color=,height=30,wrapWidth=1500) MyWin = visual.Window(size=(1280, 800), monitor = myMon, color=,colorSpace='rgb', units='pix', fullscr=True) MyMon = monitors.Monitor('LabComputer', distance=57) window, sound object, text objects, fixations. Power='75q'#intensity as string # 255 MAX This is the python code used in the previous experiment: # import modules#įrom psychopy import visual, core, monitors, event, sound rewardScore.text = "Score: " count.ToString() If (Vector3.Distance(, ) >= 1)// looks at distance between this character and the waypointĪgent.SetDestination() // makes the agent go to waypointĮlse if (Vector3.Distance(, ) = waypoints.Length) Waypoints = GameObject.FindGameObjectsWithTag("Waypoint") //finds any gameobject labbeled waypointĪgent.SetDestination() Public GameObject waypoints //defining waypoints Public UnityEngine.AI.NavMeshAgent agent Public class Level1Script : MonoBehaviour This is my Unity code that moves the user (the void Punish() is where I would like to put the code to trigger the shock): using System.Collections My question is, is it possible to connect Unity to PsychoPy to run this script, or connecting Unity to the shock machine directly? We are using a shock machine that has been used in previous experiments to shock participants using some Python code ran in PsychoPy. I have tried to find answers but cant find the help I need. However, I am new to Unity and programming in general, with a lack of knowledge in how to connect hardware to use in unity. I have developed an environment where the user is moved towards certain tokens that when collected, either reward the user or gives them an electric shock. I am a PhD student designing an environment in unity to test human threat processing. ![]()
0 Comments
Leave a Reply. |