- Home /
2D Autoscroller Glitches
My friends and I wrote a simple 2D autoscroller called "Space Escape," where the premise is a character is trying to escape an infinitely long space ship. The character can invert gravity to avoid crates that are stacked up. The only issue is, we have some glitches with the character when he "glides over" a crate and I'm certain it is related to how we implemented it.
So our game character is fixed in the center of the screen (initially), with his x position frozen and his z rotational position frozen. His y position is not, since we gave him the ability to "invert" gravity and flip to the top of the screen. We spawn our floor tiles, ceiling tiles, and crates on the right side of the screen (off-screen) and give them leftward velocity so that they are the objects that are moving. They have scripts attached to them that destroy them when they go off-screen again to the left of the game's view. Over time, the crates eventually push the character off-screen (which ends the game).
So the issue is, with the character's x position frozen, whenever we "flip" gravity to move to the top of screen to avoid a crate, if we happen to run into a crate, instead of being pushed leftward, the character glitches out a bit. Sometimes he moves left, other times he doesn't, and some times he even moves forward. I'm fairly positive this is because we are telling Unity to lock his position, but the physics engine is trying to move him.
What is the best way to address this? We need the character to be naturally be able to be pushed off the screen, but his position needs to be locked, otherwise, when a crate hits him, he will have negative velocity, instead of saying stationary after the collision. We all took a semester on game design with Unity, but it seems we are missing many vital things. Any suggestion on how to fix the glitches, or even the general approach to entirely reimplementing this, would be greatly appreciated.
Excuse the graphics, we are not graphics artists.
Your answer
Follow this Question
Related Questions
Object Changing Y Coordinate in Game View 0 Answers
Any good NEW 2D side scrolling tutorials? -1 Answers