Make platformers without a physics engine | Talk by Sergey Lerg | Made With Defold Jam 2024
Summary
TLDRThis video discusses how to develop platformer games without using complex physics engines, arguing that most platformers don't need the features of full physics simulations like bounciness or momentum transfer. Instead, the focus should be on simple collision detection, gravity, and character positioning. The speaker shares techniques such as using quad trees for efficient collision handling, adjusting movement behavior with integers to avoid float precision issues, and customizing unique game mechanics. By removing unnecessary physics complexities, platformer development becomes simpler, offering more control over game behavior and creating more fluid, enjoyable player experiences.
Takeaways
- 😀 Platformers don’t need complex physics simulations; collision detection and simple collision resolution are sufficient.
- 😀 Using a full physics engine like Box2D can introduce unnecessary complexity and issues, such as jittering and unpredictable character behavior.
- 😀 Simple data structures like quadtrees can efficiently manage collision detection in platformers by subdividing the game world into quadrants.
- 😀 Circle colliders are a practical solution to avoid float precision issues, allowing characters to slide smoothly over imperfections in the environment.
- 😀 Using integers instead of floats for position calculations can prevent problems like characters getting stuck on small imperfections in the level geometry.
- 😀 Collision resolution can be done manually by checking displacement along axes, applying the smallest correction to stop object overlap.
- 😀 When characters collide at corners, velocity direction can help determine which axis to resolve first, maintaining fluid movement.
- 😀 Jump anticipation and coyote time mechanics make platformers feel more responsive, allowing players to make jumps even if they are not perfectly positioned.
- 😀 Moving platforms can be easily handled by simply adding the platform’s velocity to the character’s, rather than relying on complex physics systems.
- 😀 Level design can be much quicker and easier without a physics engine, and tools like LTK Level Editor enable fast, efficient creation of grid-based levels.
Q & A
Why are full physics engines like Box2D unnecessary for platformers?
-Full physics engines like Box2D offer features such as bounciness, joints, and complex collision responses, which are not needed in platformers. Platformers primarily require basic collision detection, gravity, and simple movement handling, making physics engines more of a hindrance than a help.
What are the key components needed to handle physics in a platformer without a full physics engine?
-For a platformer, the key components required are collision detection, gravity (a simple formula), and a way to resolve collisions, such as displacement checks. Using basic structures like position and velocity vectors is sufficient, without needing advanced physics simulations.
What is the problem with using floating-point values for position in platformer games?
-Floating-point values can lead to precision errors, causing small discrepancies where characters might get stuck on small surfaces or not fit into tight spaces, even when they should. This issue can be mitigated by using integers for positions or rounding the floating-point values before checking collisions.
How can you optimize collision detection in larger platformer games?
-To optimize collision detection, you can use quad trees, which recursively subdivide the game space into quadrants. This allows you to only check for collisions within the same quadrant or neighboring quadrants, drastically reducing the number of checks needed.
What are Circle Colliders, and how do they help with collision issues in platformers?
-Circle colliders are used to represent objects like a character’s head or the ground in platformers. They help avoid small, precise issues that can occur with rectangular colliders, such as characters getting stuck on small imperfections in the ground.
Why does the speaker recommend using integers instead of floats for position in platformers?
-Using integers instead of floats for position ensures that there are no small precision errors, which can cause characters to get stuck in narrow spaces or trip on minor surface imperfections. Integers guarantee that the character fits perfectly in the game world.
How can you handle moving platforms in a platformer without a physics engine?
-For moving platforms, you can simply add the velocities of both the character and the moving platform together when updating the character’s position. This allows the character to appear as if they are standing or moving with the platform without the need for complex physics simulations.
What is the significance of using 'coot time' and 'jump anticipation' in platformers?
-'Coot time' allows the player to still jump for a short time after leaving a platform, improving responsiveness. 'Jump anticipation' lets the player press the jump button while in the air, and if the time between button press and landing is small, the game will register the jump, enhancing control and fluidity.
How does the speaker suggest implementing collision resolution for dual-axis overlaps?
-For dual-axis overlaps, where the character collides with two objects at the same time (e.g., a corner), the game should prioritize correcting the axis with the greater displacement. For instance, if the character is moving horizontally with higher velocity, they will be pushed vertically to resolve the collision without interrupting their horizontal movement.
What tool does the speaker recommend for designing platformer levels, and why?
-The speaker recommends the LTK Level Editor, which simplifies the creation of grid-based platformer levels. It allows developers to design complex levels quickly and export them in JSON format, making it easier to integrate them into the game engine.
Outlines
This section is available to paid users only. Please upgrade to access this part.
Upgrade NowMindmap
This section is available to paid users only. Please upgrade to access this part.
Upgrade NowKeywords
This section is available to paid users only. Please upgrade to access this part.
Upgrade NowHighlights
This section is available to paid users only. Please upgrade to access this part.
Upgrade NowTranscripts
This section is available to paid users only. Please upgrade to access this part.
Upgrade NowBrowse More Related Video
5.0 / 5 (0 votes)