chrismaltby / gb-studio

A quick and easy to use drag and drop retro game creator for your favourite handheld video game system
https://www.gbstudio.dev
MIT License
8.59k stars 475 forks source link

Player walk animation not played when moving while thread is running #1645

Open Rebusmind opened 2 weeks ago

Rebusmind commented 2 weeks ago

Describe the bug When the player is moved via an actor move event while also a thread is moving another actor, the movement animation is not played.

To Reproduce See this script: grafik When I disable the thread, the player walks normally.

Expected behavior The walking animation should be played even if a thread is running.

Screenshots With the thread running in parallel: With Thread

Without thread: Without Thread

Platform (please complete the following information):

Additional context This only seems to affect the player, other actors can walk at the samt time with no issue.

chrismaltby commented 2 weeks ago

Hi @Rebusmind just spent a little time investigating this, I believe it's caused by the exact same issue as https://github.com/chrismaltby/gb-studio/issues/1644 that you raised earlier. As soon as you start a thread it's causing the script to become unlocked, which is currently needed to allow multiple threads to run at once but has the side effect of causing topdown_update() to run at the same time too. topdown_update() is responsible for moving the player when your press input (what you saw in 1644) and also for stopping the player animation when no input is pressed (the issue you're seeing here)

To me it seems like there needs to be a way for switching between

Or something that ends up with a similar result. I'll need to have a think how best to achieve this and how to not break any existing projects in the process.

Rebusmind commented 2 weeks ago

That makes sense. Maybe threads could have a checkbox for this titled "Disable player input"? Might be too abstract, though. And it would have to work with every scene type.