Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | JohnMaddenGodot |
I have an enemy that crawls along walls and ceilings. When it hits a corner, an Area2D on its side detects it, changes its gravity to push it against the wall, changes its speed to move along the wall, and rotates itself. When it steps off a corner, an Area2D on its bottom corner detects that it has left a tile, changes its gravity to push it against the wall, changes it speed to move along the wall, and rotates itself. It mostly works fine, however sometimes when I test it, it will hit a wall/leave a corner and not rotate itself, and either keep pushing against the wall or fall backwards if it has left a corner because of gravity not changing. But sometimes when I test it without changing anything, it behaves as it should. Additionally, adding/removing a tile on its path will make it behave as it should. What could be causing this?
I’ve done some more testing, it appears to only happen when it is traversing a L-shaped segment that is two tiles on each side. That is, if it turns onto a platform that is two tiles long, and then traverses up a wall that is two tiles long, when it turns at the top of the platform it will fall back down to the bottom, as it appears that gravity has switched before its hitbox reached the next platform.
I seem to have fixed it, made it check for movement speed to be greater/less than or equal to 0 instead of just greater/less than.
JohnMaddenGodot | 2022-05-30 21:38