Hi, I've ran into an issue related to a flying-enemy which I believe is significant to look into.
Before I begin to explain it, the enemy consists of a bird that flies in the sky, impersonating as a common background element, but when the player passes under it, the bird plummets down below at quick speeds crashing to the ground, and then gets up again and turn in the opposite direction, this is the "core" idea.
This works perfectly well (although it's not very polished yet), the problem is when the bird gets up. I'm using a "wake up again" timer that initially causes the bird to gradually move upwards, and after then sets its state value to 4, that causes it to stop moving. It kinda works, but it doesn't take into account if when the bird goes over the Y position where he was before falling, since it's just using a timer value.
Now, I guess you could say that I could solve this quickly by setting an initial Y position value of the bird at the start of the frame and then checking to see if the Y position upon moving up is lower than that value. But I've tried that and although it works better than using the timer, it's kinda very janky as it bugs sometimes and doesn't work as intended.
I could give an MFA or even a simplified version of this problem, as I think it's a deep issue that someone could understand better by looking at the code, if that's okay.