Devlogs
Coding Dev Log (Robson): Fixing Push Bugs and Tackling Camera Conflicts
Posted November 20, 2025 by Sennris
#GameDev #Coding #Debugging
Robson has had a productive day, successfully resolving the three major bugs that emerged with the implementation of the new Push Feature. However, in the process of ensuring visual polish, a new, complex issue arose concerning the interaction between the camera shake and the parallax background.
Push Feature Bugs:
The challenges related to the movable square inheriting the player's movements have been addressed and resolved:
- Resolved: Push square flips with player
- Problem: The square would instantly jump to the other side of the player when the player changed direction, which was unrealistic.
- Cause: The player's direction-flipping function was affecting the entire player object, including its children.
- Fix: Robson implemented a conditional statement that disables the flipping code specifically when the player is currently pushing or holding the square, keeping the object stable.
- Resolved: Push square jumps with player
- Problem: The square would be carried into the air with the player's jump and would float if the player released it mid-air, which was unrealistic for a heavy push object.
- Cause: The jump code affected the entire player object, including its children.
- Fix: A conditional was added to the movement script that states the player can only initiate a jump if they are not currently pushing the square. This prevents the undesirable physics interaction entirely.
- Resolved: Damage dealt to player when touching with push square
- Problem: Pushing the square into a damage-dealing object resulted in the player taking damage, as if the square itself was part of the player's vulnerable body.
- Cause: The damage detection system was too general, detecting any child of the player object as a target for damage.
- Fix: Robson added a specific tag to the push square object. The damage detection script was then updated to only register collisions with the player's main body, using the new tag to differentiate and ignore the push square.
New Challenge:
With the Push feature stable, Robson moved on to testing the compatibility of the previously implemented Screen Shake effect with the game's Parallax Background—and discovered an immediate conflict.
- The Problem: When the Screen Shake effect ends while the player is moving, the camera ends up offset from the player's position instead of resetting cleanly.
- The Initial Cause: The Screen Shake coroutine defined its "start position" as the camera's location at the beginning of the effect. If the player moved during the shake, this fixed "start position" would no longer correspond to the player's actual location at the end of the shake.
- Initial Attempted Fix: To solve the offset, Robson changed the camera logic to always set its position directly to the player’s current location at the end of the shake.
- The New Problem: This fix immediately led to the Parallax script returning a string of Infinity or NaN (Not a Number) values in its vector calculations, effectively breaking the background movement.
The Deeper Cause: The parallax script relies on dividing by certain positional values. By constantly setting the camera's Z position to the player's Z position (which is 0 in 2D space), one of the values in the parallax calculation is becoming zero, resulting in a "divide by zero" error, which manifests as the Infinity/NaN values.