Repository navigation
InputWalkBehavior: Check if the player got stuck - #2777
Conversation
|
Play this branch at https://play.threadbare.game/branches/endlessm/input-walk-behavior-stuck/. (This launches the game from the start, not directly at the change(s) in this pull request.) |
|
Doesn't work :/ Grabacion.de.pantalla.desde.2026-08-20.16-30-48.mp4The "is stuck" check seems reliable. It doesn't give a false positive running in front of elevation or water, for example. But the character can still get stuck (although less than before). Someone from my local Godot community recommended me to report this bug upstream. I can do that. |
And if so, set velocity to zero and go back to the previous position otherwise. Helps #2704
Add a 2 seconds timer and use it to call defeat on timeout. Start or stop the timer depending on the input walk signal "is stuck". Add a shaking animation to the player sprite when it becomes stuck.
9dbb772 to
f045737
Compare
|
I have repurposed this. Now the player will become defeated after 2 seconds of getting stuck. Which is not ideal but is slightly better. A level designer could put a hookable pin on water. I added an example of this to Dev Archipelago: Grabacion.de.pantalla.desde.2026-09-10.15-46-44.mp4 |
| # Check if the player got stuck (is colliding after the move_and_slide). | ||
| var collision := character.move_and_collide(Vector2.ZERO, true) | ||
| is_stuck = collision != null |
There was a problem hiding this comment.
move_and_slide() affects various state variables of the CharacterBody2D so I was curious whether move_and_collide() does, too. Now I understand the importance of the second argument, test_only = true!
|
Great, this is better than being blocked forever and having to manually do the same thing. I think the timer makes sense because you could imagine situations where it's temporary, e.g. being squidged into a corner by an NPC which then moves the other way. |
And if so, defeat the player.
InputWalkBehavior: Check if the character got stuck
That is, if after calling move_and_slide() it still collides with anything.
And emit a signal when this state changes.
Player: Defeat after being stuck for 2 seconds
Add a 2 seconds timer and use it to call defeat on timeout. Start or stop the
timer depending on the input walk signal "is stuck".
Add a shaking animation to the player sprite when it becomes stuck.
And if so, set velocity to zero and go back to the previous position otherwise.
Dev Grapple: Add example of pin positioned in water
Helps #2704