I have a number of questions relating to using a 2D physics engine in a platform game, but one main one that I'm grappling with at the moment. I managed to somewhat integrate the Physics2D.Net engine into a Scrolling Game Development Kit 2 project. I'm very pleased with the performance and the realism of the physics. However, I've lost some things that my original SGDK2 physics engine (oriented more specifically to platform games) made easier:
- Riding on a platform is very difficult now. This is my main question. It's not difficult to implement, but difficult to play. Assuming I even do manage to get the player onto a platform (which is hard enough in itself), as soon as the platform moves, the player falls off because there's not enough friction between the player and the platform or something. Do I just need to tweak things like friction, inertia, linear velocity dampening and the like to make it easier to ride on a platform, or is there something fundamentally difficult about riding on platform is the "real" world? I've tried reducing the force applied to the platform that makes it move (so it would allow more time for the rider to match the platform's velocity), but then that's not enough force to keep the rider aloft, and the platform sinks to the ground. I'm simply applying forces to move the platform.
- What is the best way to stop the platform from rotating? I've tried setting the Angular momentum and the angular position to 0 on each frame, but this can result in little twitches that cause anything on the platform to spring into the air a bit, just long enough to fall off.
- Running along the ground: How do most platform games with realistic 2D physics implement the player? My player is currently a square, but will often tumble and spring into the air due to friction hitting one of the corners. My guess is that the player should be a circle and always drawn upright. Is this standard practice, or is there another way? If I use a circle I expect that riding a platform will be even more difficult! The player will roll right off. I'm thinking of Little Big Planet, which also seemed to keep the player on the ground pretty well. Do I just have to put a lot of velocity damping on the player, or something like that, if I want to keep them grounded too?
- Since SGDK2 is a tile-based engine/IDE, I have writen code that analyzes all the shapes of the terrain/tiles and turns them into physics bodies with infinite mass (merging them horizontally, but not vertically where appropriate; merging two directions was too difficult for me to figure out because I couldn't figure out how to trace and represent the hole in a torus-like formation). Is that a good way for a platform game to implement something for the sprites to interact with to represent the solid ground? Am I better off turning each tile into a physics body (few simple shapes, many bodies and internal surfaces between tiles), or merging them as I am doing (fewer bodies, but more shapes that are more complex)?
- I'm having a hard time figuring out the optimal vertex subdivision level and grid spacing to use. I don't really understand these concepts and documentation on Pysics2D.Net is sparse to non-existent as far as I can tell. I am generally subdividing to about 6 and using a grid spacing of about the same. My sprites and tiles are mostly 32x32 units (pixels), all square for the moment.