When are the the callbacks invoked? I have a move method invoked from an action callback. It uses delta time and behaving very erratically. I’m getting 250 frames per second, and when I do a VSync to 70 fps it starts to behave smoothly.
So clearly the Time.deltaTime is incorrect whenever the method is invoked. Howevr it could be about other timing and input value issues. The movement I’m talking about is actually camera rotation from mouse delta.
But when I remove the delta time and try again with no VSync it acts smoothly. So it’s not an incorrect mouse delta, it’s incorrect Time.deltaTime.
Found it. Whenever there are frame time spikes it jumps in the direction of input, sometimes a lot. It overcompensates. This happens only in editor. Causes very inconsistent control behavior, for example rotating camera with small mouse movements left and right in 15 degree ark might cause up to 180 degree jumps when there are spikes (every 1-5 seconds, when editor under.
I simplified the rotation code just to make sure problem is not there:
I suspected that, but cant find information on when the callbacks occur and if there can indeed be more then one per update.
So in this scenario… I’m kinda out of ideas. If I store the input and apply it on update that would be so messy. Should I accumulate mouse delta until update, pass it, nullify, repeat?
As a rule of thumb, every input event that changes something bound to an action will trigger the action once. There’s lots of exceptions but still, architecturally actions operate at the input event level and are oblivious to frames.
Mice are generally sampled at high frequency leading to lots of input events. Frame spikes can thus lead to an accumulation of a large number of events and thus actions firing a lot in response.
Thank you. Will that account for all mouse input that happened since last frame?
If yes, good. If not wouldn’t that lead to some lost input? It wouldn’t be as bad as accumulating callbacks, but still some inconsistency with physical input.
It will read the current value only. However, I assume you have CameraRotation bound to the mouse delta. Delta controls are special in that they accumulate. Meaning that instead of just overwriting the mouse delta each time there is a new event, they will add the newly received delta to the current one and then reset the delta to (0,0) at the beginning of the next frame / input update.
So, in essence, you’ll read the final accumulated delta from the entire frame in this case.
Right. That’s great. Although, I am kinda disappointed with how inconsistent my input API usage is right now.
First I tried to do everything via PlayerInput invoking events. Turns out I can’t invoke Vector2 event.
Then I tried to do everything with callbacks. Turns out there is no callback for Input.GetKey-like event, alright I made a very awkward system that takes performed callback and cancelled callback. (8 lines of code… instead of 1)
The only thing then… I have a feeling that there is no way to check via action that key that triggered the action is still down. If there is, then I’m good to go.
Something like _inputActions.BuildMode.PrimaryAction.inProgress
Isn’t that the second or first most commonly needed functionality?