Mouse buildup on start

Jaakk0S

New member
Hi!

Hi guys, been a while since last asking anything!

I'm having an issue where, at least in editor, there's like mouse position buildup while the game starting that will fire when the level starts. After pressing play on the editor, if I don't touch the mouse, the character will start facing jut forward. But if I move the mouse, this movement will fire immediately after the player becomes active.

So I'd like to clear this "movement buffer". I tried to make a startup delay before switching on "OnEnableGameplayInput" but didn't get this to work. Actually I'm not sure where the root cause is. I'm using the new input system.

Anybody else seen this? Any ideas?
 
This fixes the issue, however I'd like to know if there's a smarter way cos this is just a dumb timer.


C#:
void Awake() {
    InputSystem.DisableDevice(Mouse.current);
    StartCoroutine(EnableMouseAfterDelay());
}

private IEnumerator EnableMouseAfterDelay() {
    yield return new WaitForSeconds(0.1f);
    InputSystem.EnableDevice(Mouse.current);
}

I'm suspecting the point where the movement triggers is when the character is attached to the CameraController which has a delay. The issue is fixed with the delay of 0.1f here but 0.01f will not work.
 
Last edited:
Top