Terasology
Terasology copied to clipboard
Don't send CharacterMoveInputEvent if I don't input anything
Motivation
During a debugging session I noticed, that the LocalPlayerSystem
sends a CharacterMoveInputEvent
every tick, even if I'm not pressing any key and not moving the mouse at all.
See https://github.com/MovingBlocks/Terasology/blob/develop/engine/src/main/java/org/terasology/engine/logic/players/LocalPlayerSystem.java#L175-L176
This does IMO not only create a lot of unnecessary events that might negatively impact, but it also creates a lot of "noise" and makes it harder to debug.
Proposal
Exit early from LocalPlayerSystem#processInput
if there is no input, e.g. no keyboard input creating movement and no mouse or VR input creating view rotation.
My hope would be that this improves performance and reduces unnecessary noise.
@pollend @keturn @DarkWeird I have no clue whether or not this is a low-hanging fruit - might be. If I missed any other inputs this might try to process, I'd be interested to learn which.
This does seem worth looking in to. Good catch.
#4586 may have some other ideas to keep in mind while working on this.
Irc, CharacterPredictionSystem send this event too. Noticed for mob, while working with FlexableMovement
A wild guess on this: gravity on characters seems to come from apply downwards pull on every (affected) movement event. Therefore, might it be necessary to send "dummy no-change events" just to have the gravity be applied to characters each tick?
And since we only do this repeatedly for the player characters, NPCs are affected by gravitiy as soon as they move (e.g., walk or jump), but are not affected by gravity if just standing around... 🤔
That actually makes sense :see_no_evil: I would argue that this should ideally be done separate from actual movements, but guess it's quite entangled at the moment and hard to "unfiddle"