Generating a smoothly moving dot

If this template helps then use it. If not then just delete and start from scratch.

OS (e.g. Win10): 7
PsychoPy version (e.g. 1.84.x): 3.0.0
Standard Standalone? (y/n) If not then what?: Y
What are you trying to achieve?: Generating a smoothly moving dot.

What did you try to make it work?: I generated a routine. Within the routine I defined a polygon (dot).
I created a conditions file with x and y coordinates of the dot to update. When I run the experiment the dot moves in a circle as expected but it flickers. How can I create a moving dot that updates its position without flicker? Maybe I have to add something in the “each frame” code component?

Thank you very much!

Hi @M11, if you are using Builder, you just need to modulate the shapes position by a small enough value on every frame (screen refresh). In the example attached, the position of the circle is updated on every frame, using sin(t)*.5, where t is time in seconds.

circle.psyexp (4.1 KB)

Hi @dvbridges, thank you very much for the prompt reply.
I tried to run your file but the dot is not moving (the dot remains always in the same place).
Is there anything I have to add (e.g. a loop?). I also tried to exchange the ‘t’ of the formula by a value (e.g. 0.5) but nothing happened.

Thank you!

Must be that your screen units in experiment settings are set to pixels, which would mean that the dot position will only change for values within a range of 1 pixel. Try changing them to height units, and the circle should move.

Just great! It works! Thank you very much.
May I ask a last question. How can I vary the speed of the dot (e.g. that the dot moves faster)?

Thank you very much again.

You could multiply variable t by some value, where higher multiplication values give faster movement e.g., (cos(t*5)*.5, sin(t*5)*.5)

All works fine! Thank you for your time! You really helped me a lot.

Sorry for another question regarding the topic above.
When I run the program of @dvbridges everything works fine.
However, adding another moving polygon or replicating the exact same steps (in builder) in another PsychoPy program does not work (in experiment setting I checked for the correct units “hight”, I copy and paste the formula, I set the position to “set every repeat”, and I checked that all the other parameters have the same values like in the example of @dvbridges). With “another PsychoPy program” I mean that I simply opened a new PsychoPy file to rebuild the example program by myself. I use PsychoPy 3.1.0.

What I am doing wrong?

Thank you!

If not working means the dot will not move, try setting to update “each frame”, so the position of the dot is updated on every screen refresh, rather than every routine (every repeat).

Great, it works. Thank you very much again!

Do you not use a conditions file in this circumstance? I have been trying to use the x,y coordinates in a conditions file to get a polygon to move across the square in a direct line on one trial, but can’t get it to accept my conditions file in the position input line