Player input independent of frame rate?
Hi, I'm trying to work out the best way to calculate player input independent of frame rate? ie. if the game stutters or player changes to a lower/higher frame rate, looking around in first person always feels the same.
I know Unity is working on separating input from the main thread in a future update, but has anyone any ideas on how best to go about it currently? (version 5.3.5/5.4)
If I do all my input calculations in FixedUpdate it seems to work nicely, but I get a strange stuttering effect which looks to be caused by the framerate and the input being out of sync sometimes.
If I calculate everything in Update, I can't seem to then get it to be framerate independent, as input will feel broken at low frame rates and way too sensitive at high ones.
Any help or ideas would be very welcome, cheers!
What are your "calculations"?
If you just mean to make your character move with the same speed in any framerate, you just need to add time dependeny with the factor Time.deltaTime, like in any movement or animation, actually.
Also it is not good to retrieve the input in FixedUpdate() as input is working per frame, e.g. $$anonymous$$eyDown() returns true during the frame that the user started to press the key. When retrieving this in FixedUpdate(), some of it might get lost.
Your real problem is not the input, your problem is the framerate, if you have low frame rate try reduce your resources or use the profiller
Answer by AurimasBlazulionis · Sep 09, 2016 at 04:33 PM
Simple answer. Now you can't. Unless you write your own library for getting inputs, but then you will have to compile it for every platform you want to use.
Yea, Unity say they are working on separating it from the main thread, but I'm wondering what the best way to go about it or get close to it at the moment would be