I'm currently trying to create a 2D platformer puzzle game like Mario vs. Donkey Kong: Mini-land Mayhem! within Flash. My issues reside in the bridge collision with the walking AI.
The game allows the player to create a bridge from one end point to another at any angle. Then the player's AI mummies (in this case) walk across the bridge to reach another platform.
Now, seeing that the bridge can be constructed at any angle, I'm only going to have a rotated rectangle to represent the body of it.I obviously can't use the typical AABB to check collision against this, instead it looks like I'm going to need to do a SAT or pixel perfect check.
The AI mummy must always stick to the platform or bridge as it walks across it (not to mention rotate to the bridge's angle). Therefore, I suppose I'm going to need some gravity and sliding collision? The walking speed should also be the same on both the platform and bridge.
Lastly, since I'm using a grid for my platform tiles (including the end points) connecting a bridge to them isn't going to be perfect. Going up and down the bridge may need some offsetting with floor in order to make a smooth transition from or two the bridge.
Some things I have tried in the past week or two:
- Using SAT collision with rotated rectangular bodies on the mummy and the bridge. I tried having the mummy walk up the bridge by adding 3 mini-hitboxes on the bottom-left, bottom-mid, and bottom-right to him. I had a hard time trying to get this to look right and trying to stick all of the hitboxes onto the bridge and the floor (especially when I rotated the mummy to that of the bridge).
- Using Box2D Flash port library. Just doing something simple as this is seeming like an uphill battle with this physics engine. It looks as if it will be troublesome to get a predictable movement with a constant speed especially when going up the bridge. I've tried their 'conveyor' example, but for some reason, the classes that were used for it are missing in the Flash port. I've also tried disabling the physics and just using it for collision detection, however I dislike it entirely. I also don't receive any contact information for collision on the sensors (like distance, normal, point of collision, etc.). I'm better off with using my own SAT implementation for this task.
- I've also tried placing nodes above each end point and when a bridge is connected, the mummy will know to go from one node to the other when he collides with the starting node itself. This has drawbacks of needing to offset the nodes perfectly so the mummy's feet will always be on the bridge, so I'd have to make sure to never change the size of the character and the bridge. Also, I'd need two nodes per end point, since going down and up a bridge will need different offsets.
It feels as though a fully fledged physics engine just doesn't feel right for this game. It would handle a lot of my current problems, but it will be introducing more at the same time. If I want a smooth walking transition from the platform to the bridge, it seems as it's the only choice.
Now my question is how would you guys go about having the mummies walk up and down a bridge smoothly at a constant speed and angle? Just use a physics engine? Create your own physics? Or trying raycasts?
Thanks