I can't post a MFA because this is a personal project, but I can describe this situation.
I am working on a platformer and am in the process of adding pushable boxes.
I have 2 identical characters that can both push boxes. Their physics and code are identical. The first one has NO issues when pushing boxes.
When a box is pushed to the right, the X position of the box and character are raised by 0.5 per frame. All sensors are also positioned on the character to insure that they stay in-sync with the characters movements.
The first character works flawlessly. The second character, with identical code/physics etc, ends up triggering extra code that should only trigger when his hitbox+floor sensor are overlapping an obstacle. This would imply that the sensor is getting out-of-sync with the character by at least 1 pixel and overlapping the box, but if you step through the game 1 frame at a time, this NEVER happens. I've done lots of troubleshooting and the only thing that fixes this is moving the positioning code for the sensor in question closer to the bottom of the events (There are over 700 lines right now. It was around line 235 and now it is at line 698, but still takes place before the box pushing code - lines 700-710.) The first character works the same with his positioning code still at the top.
I know code is read top to bottom, but can someone explain to me what is going on? Moving this line down fixed the problem, but it throws the organization of my code off a little bit and it bothers me a bit. If I only move the line down a few hundred lines it doesn't fix the problem. There is a certain distance I have to move it before the issue is resolved. Can someone explain why moving the code down could cause the game to function differently?