Skip to content

Ensure that animations never run in observer mode#885

Open
TomWerner wants to merge 1 commit intoDevelopmentfrom
twrner/fix-observer-animations
Open

Ensure that animations never run in observer mode#885
TomWerner wants to merge 1 commit intoDevelopmentfrom
twrner/fix-observer-animations

Conversation

@TomWerner
Copy link
Contributor

@TomWerner TomWerner commented Feb 16, 2026

This avoids any issues with the "shift" key toggling animations colliding with the "ctrl+alt+shift+o" shortcut for observer mode.

@TomWerner TomWerner requested a review from stavrosfa February 16, 2026 04:14
Copy link
Contributor

@stavrosfa stavrosfa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to bake the observer mode not having animations in the code? I think this is more of an Animation issue and that all the units are moving at the same time.

That being said, I don't mind this, but I'd rather put it in the animateAsync method in MapUnit and Tile with something like

if (EngineStorage.animationsEnabled && !EngineStorage.gameData.observerMode)

or in one single place in the AnimationTracker startAnimation method
if (EngineStorage.gameData.observerMode) return;

this doesn't actually work, I suspect it doesn't pass the if (EngineStorage.animationsEnabled) check in MapUnit

If that works for you, I think it would be preferable, let me know what you think.

Perhaps also a TODO to have a future look at it if we "fix" the animations would be useful.
Now that I tthink of, another TODO for an configuration/preferences option to choose if animations are enabled/disabled in obvserver mode would come in handy someday

@esbudylin
Copy link
Contributor

Have you tried other ways of dealing with this input collision?

You can try to add an action for toggling observer mode to the Godot InputMap instead of manually handling the key combination for it. AFAIK, the engine should be able to resolve the collision and won't trigger two actions for the same key stroke. https://docs.godotengine.org/en/stable/tutorials/inputs/input_examples.html#inputmap

@stavrosfa
Copy link
Contributor

I had the exact opposite experience with Godot, I have left a comment here as well regarding this.

This also seems to suggest the same way, check for pressing T for example, and if Shift is pressed do X otherwise do Y.

Am I getting this wrong?

I don't think the best way to handle inputs is manually, but it seems to be the only way.

@esbudylin
Copy link
Contributor

@stavrosfa Hm, I've the reread documentation for Input.IsActionJustPressed, and it seems that by default it doesn't take modifier keys (Shift, Alt, Control) into account. It allows to pass a flag to toggle this behavior https://docs.godotengine.org/en/4.4/classes/class_input.html#class-input-method-is-action-just-pressed

Maybe calling this method with exactMatch flag set to true can fix this issue?

@stavrosfa
Copy link
Contributor

stavrosfa commented Feb 16, 2026

I tried to do

if (Input.IsActionJustPressed(action, true)) {
ProcessAction(action.ToString());
} else if (Input.IsActionJustReleased(action, true)) {
ProcessOnReleaseAction(action.ToString());
}

where the true boolean I am passing is the exactMatch argument

and it doesn't seem to make a difference with the current setup.

If I release Shift last from the keyboard, it enables the animations. If I release another key last, the animations stay disabled.

Not exactly a scientific way to try this, but hey 😅

EDIT: Do I need to pass the CTRL + SHIFT + ALT + O as an action though? I think it won't matter because the release action is still the Shift key, so it will do the same thing..

See the added code comment - observer mode now happily chugs along on my little chromebook.
@TomWerner TomWerner force-pushed the twrner/fix-observer-animations branch from 560c65a to aad429d Compare February 16, 2026 18:53
@TomWerner TomWerner changed the title Ensure that animations aren't re-enabled in observer mode via "shift" Ensure that animations never run in observer mode Feb 16, 2026
@TomWerner
Copy link
Contributor Author

That being said, I don't mind this, but I'd rather put it in the animateAsync method in MapUnit and Tile with something like

if (EngineStorage.animationsEnabled && !EngineStorage.gameData.observerMode)

Yeah, that seems reasonable. Done

Copy link
Contributor

@stavrosfa stavrosfa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is also this here

public async Task AnimateAsync(AnimatedEffect effect) {

I think we would want that too, if anything, for consistency

Feel free to merge this btw

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants