I got a problem in my game. I make a musical game and i need very precise input.
Input are processing into the update function (“if(Input.GetKeyDown(…))”). So the only way i find to have a very precise input, is to disable vSync and run my game as fast as he can (5 ms is the maximum “error scale” value i want = 200FPS or better).
No problem, my scene is very light and even on a Dual Core + 6 year graphic card, the game runs at 200.
Problem : I think i got tearing now. (moving object of my scene have like a “drag” behind them)
The only thing moving in the scene is all notes of music, and there’s a simple function which move them. So i try to “cheat” using “WaitForSeconds(0.016f)” for each move for the notes. But when i test it, it’s like the game run at 10-15 FPS.
WaitForSeconds seems to not work as i expected.
Anyone have a solution or an idea for what i’m trying to do ?
Mold : God, why i dont think about that before ? Thank you !
Twiik : In fact no Your game can run at 1000 FPS if you want to. Want to try it ? Make a empty scene, disable VSync (which actually force your framerate to be sync with the refresh of your screen (so 60 or 120 FPS)), and display the FPS of the scene. And tada !
I dont use GetKeyDown on FixedUpdate but in Update.
And why do it ? Because in the game, there’s precision score, and the best graduate you can get is earn when you hit a note +/- 21ms of the “point 0”.
For exemple if there’s a note at 15.250 sec, you can have the best score if you hit the note after 15.229 sec and before 15.271sec.
If my Update function runs at 60 FPS (cause of VSync), it seems that the KeyDown is verified every 16ms (every Update).
If you hit the note at 25.256 for exemple, you’re 6ms after the note, this is a great score ! But because of the 60 FPS, if unfortunaly you hit your keyboard JUST at the end of the previous frame, your hit will be noticed 16ms later, so at 15.272. And you’ll miss the best score
You have a windows of 41ms, if my game have a possible error windows of 16ms (almost 50% !), this is just not possible. 5ms is the maximal acceptable error gap i want (200FPS).
PS : I put my function in Fixed Update and set the Time.deltaFixedTime to 0.01666666f and the game is not really fluid But my computer here have a 6 year graphic card and a bit old, i’ll test it at home in a most recent machine. Thanks for your help