I'm looking into implementing rope physics in my game, like in the DOS game Worms, or like Umihara Kawase (SNES), sans the elasticity. So the rope is always straight, and bends around corners. But I'm baffled at how hard this is. Does anyone know how they did it in Umihara? Since my game is tile based it should be a good example. I'm not looking for a detailed technical analisys, I'm looking to know the concept behind it.
I've tried this approach that didn't work very well:
- Each frame I check several points of the rope for collision with tiles.
- Whenever a point is inside a tile I do a series of checks to find out which direction it was coming from so I can determine where to place the bend relative to the tile it is in.
- I check if the rope's pivot's X coordinate is smaller, the same or greater than the tile that had a collision. Then I check the angular velocity to see if it was clockwise or counter-clockwise, and based on that info I place the pivot on one of the four corners of the tile.
This caused several problems, first one is that sometimes it would collide with a wall of more than 1 tile and it would place the bend in the middle of the wall.
Another problem is that sometimes the angular velocity couldn't be trusted.
So, I thought of another approach:
- Check for collision on several points of the rope on every frame, but store their positions on a list. If it doesn't collide, this was the last good position for the rope.
- If the rope collides with a tile, I check the same point (based on array index) for its previous position to find out where it was coming from and expell it from the tile and create the bend on the closest tile corner to that point.
Just thinking about it this approach it seems better but it may also be problematic. Any ideas?
edit: forgot to mention, I'm making the game in game maker (full code mode). I'm not using physics. Not that it should matter, I'm just looking for how it was done in Umihara Kawase, in concept.