Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Need help to make flickering square on preset frequency

Discussion in 'Animation' started by T1Green, Jun 20, 2014.

  1. T1Green


    Apr 2, 2014
    Hello everyone
    I hope someone can help me with this problem since it's quite vital for my project.

    I'm working on a medi-sci project where I want the patient to use brainwaves to exercise control the environment.
    The environmnet is a 2D game where the game character is to be controlled by 2 flickering squares. Each square are supposed to be on different frequencies e.g. 7Hz and 9Hz. They flicker between black and white. These frequencies will be measured on the brain and used to move the characters in a BCI solution.

    The project is being made in Unity and in c#.

    I found out that using the refresh rate on the monitor to calculate my frequencies for the flickering squaring could only be done for the CRT monitors. Since we (mainkly) don't use CRT monitors anymore but use LCD instead, I need to find a way to do it for LCD.

    A friend told me that I should look into the Timer.Interval in C# (or just the Timer class) and use that to switch between black and white squares to get the frequency I want. I'm not sure how it would work since I didn't get much of the documentation of it so I haven't tried it out.

    On the other hand, I wonder if this could be done easier by using the 2D animation editor where I make an animation for each of the squares on different frequencies, and then add them to the right and left sides of main game character.

    Still I wonder if it can really be used to set special frequencies since animation editor is based on frames pr second (FPS). I don't know much about if you can set the frequencies you want using FSP on a LCD monitor.

    I'm a bit lost on how to carry this out and I would be grateful if someone can help me find the solution to which one is easier to implement into the 2D game in Unity, no matter which computer or LCD screen is being used. After all, I want a frequency on "precisely" 7Hz and 9Hz and not one that swings up and down dependent on other hardware and software in the computer.

    1. To get a specific flickering frequency on a white/black square, what would be the best course of action to take in Unity3D?
    2. How would you calculate the frequency? As in how would you get the frequency you need (like 6Hz) with your solution?

    If you have an example for any solution you have, I would be extremely grateful. Still, I'll take whatever I can so if you don't have any examples, that's fine too.
    Last edited: Jun 21, 2014