Video Game Concepts Vol. 3: Multi-Terrain Gravity -
09-15-2009, 12:34 AM
I was asked to make one about having separate gravity methods for both land and water, so here you go. (Also, some people asked for screenshots, so I'll do my best)
Background: In games where the only objects you can fall on are solid, you only need one type of collision method which has the objects stop when one falls on the other. For water, however, you need to add another method which allows the object to sink, either partially or completely, under the water's surface.
Explanation: When an object falls into water in reality, it sinks at least a little bit no matter it's weight or density. This is another part of the game's physics, as there needs to be a special provision to prevent the object from walking on water or from sinking forever.
Example: In this world, the penguin immediately falls to the island. Both he and the island can be moved and when he is no longer above any part of the island (even the outer edges), he sinks into the water partially and bobs semi-realistically. I even solved the problem which made his feet partially sink into the island in Vol. 2. Key Ideas: First, a method determines if the penguin is above the island or not. Then, another method determines how far down he falls. To solve the problem which let to his feet getting buried, I changed the original method to stop moving him down when he was less than a certain increment (0.04 meters) above the island (or water), then pass it off to another method which moved him down to the island (or water) in zero seconds, making him ultimately move the exact distance to the island (or water) seamlessly. To make the penguin stop midway in the water, another object (I call it a marker) must be added. I used a bump shape, then moved it to the positionI wanted in the penguin,
then it made it's vehicle the penguin and set it's "is Showing" to false. This way, the penguin can easily sink down to any level I choose by setting the marker to whatever level I choose.
Application: Same as normal gravity, new objects must be added to a list to be affect by gravity. The only provision you'd need to make (which I didn't make in this world) is a way for the object to get back on land somehow, as moving the island back over the penguin won't cause him to rise to rise back to the top of it.
EDIT: I figured out how to delete the giant, problematic screenshot, so I'll try to re-post a smaller version next.
EDIT2: I spent a lot o' time on it, and I really can't find a good way to get small but readable screenshots. If anyone knows how, please tell me.
Last edited by x2495iiii; 09-15-2009 at 08:09 PM.
|