|
 05-14-2009, 11:40 PM
 |
Delzhand wrote:

|
I think it's a kid in a giant soup can, and I think it looks amazing - sort of like a mech without anime-baggage.
Also, how do you handle moving platforms? Do they exert a force on the player object, or is the player somehow rooted to the while stationary? In my platformer the player is moved the distance between the platform's last and current position, but that would never work for rotating platforms.
|
In the physics engine, all characters capable of walking run a routine called "seek ground" that looks 10 pixels in each direction from the bottom edge of their hitbox. If it finds ground, it aligns the bottom of the hitbox to the highest point. This allows characters that walk on arbitrary ground shapes. The amount of vertical adjustment is recorded but not factored into real velocities. That way, the player doesn't become unglued from the ground so easily but when another object needs to inherit your velocity, such as a projectile you're throwing, that object can inherit the Y velocity and the ground adjustment for proper behavior.
This means that vertically moving platforms, no code changes are necessary. I just change the collision mask on the ground and the objects notice they've become embedded and shoot to the top. For horizontal movement of platforms, I added a variable to the basic PhysicsObject that allows for an external horizontal velocity.
Moving platforms have attached a hitbox that when entered by any object, set this variable. It's recalculated every frame, so I just read off the velocity of the platform object directly and push it to any objects in the platform's influence.
The rotating platforms are a cheat. I create an object that appears to be a moving platform, but I override the physics methods that would normally add up accelerations into velocities into positions, so they remain stationary. The hitbox that would normally keep the player fixed in place by matching velocities then pushes the player to the left or right, depending on what I set the velocity to. I don't bother calculating the real rotational velocity because I don't have to. The seek ground code keeps the player moving on a circular path and the steady horizontal velocity looks good enough. |
__________________
|
| #122
|
|
|