Tracking head movements and inserting images in VR

Hi folks,

I’m a postgraduate psychology researcher and am looking to use unity to create an experiment - I’m essentially looking to track head movements while multiple 2D images are displayed on a board/screen in VR - the background of the environment should be relatively basic - a blank room with a central screen/flat board on which static images can be displayed. I would like an output of the head movement data, preferably to a csv file.

Coding is relatively new to me - I have some experience in Matlab, but none in C#. Is this something that unity is capable of doing? and do you have any tips or links to relevant tutorials?

Thanks.

Head tracking — or at least, accurate head tracking — is really hard. Unity can easily handle drawing the room, but for accurate head tracking, you’re going to need some extra hardware. Pick the hardware first, and then look at interfacing it with Unity. (Any system you pick probably already has a Unity plug-in, as Unity is so popular.)

Thanks for your reply - I should have mentioned i’ll be using a oculus rift. I’ve downloaded the oculusUtilities package and I believe its possible to code the camera to give an output of head movement. Although I haven’t tried this yet. I’ve built a basic environment with a central cube that will act as my display screen. I’ve imported a few test stimulus and added these as textures to this central cube - and fiddling about to find the right viewing distance etc. I’m now trying to work out how to code to cycle through a list of these textures on key press or after a display interval of say 30 seconds.

OK, sounds like you’re off to a good start.

Give your script an array of Texture2D (or maybe Sprite, depending on how you’re displaying these things). Put this script on the object where they should be displayed, and assign all your textures in the inspector.

Now to respond to a key press, just check Input.GetKeyDown in the Update method. To change based on time, instead check Time.time (also in the Update method). When it’s time to change, then use GetComponent to get a reference to the Image or Renderer you want to update, and assign the new texture to it.

That should be enough search keywords to get you started, at least! :slight_smile: