I am trying to use a device connected to an arduino which can output "1"s or "-1"s to control movement forward and backwards of the player object in my game. However the device/arduino is capable of sending signals at a much faster rate than the frame rate of the game.
I want to be able to accumulate all of these signals during a frame on the Unity side, then use this accumulated value to move the player object (so essentially a greater positive or negative value during the accumulation period will translate to a higher movement velocity than a smaller one), at which point I would reset the value to 0 and repeat this process. I’m able to do this and have it working in a C# script, however what I am having issues with is coming up with a way to have Unity poll the arduino at a rate which is faster than update(). I have been following this guide among others (I don’t want to paste the code here as it isn’t my own, but it is the code under the section “Part 2” - the arduino code I am using is different but the same concept of sending information using Serial.print()), however based on the debug log I seem to be missing any values that occur between update calls.
I am wondering if there is a way to have Unity poll this device outside of update at a high frequency (essentially to get every single serial data output from the arduino). I have come up with some work around solutions that typically involve doing the value accumulation on the arduino side but I would like to know if it is possible to handle the raw serial input within Unity, and if there are maybe some resources that would help me better understand how to do this.
Thanks