-
Notifications
You must be signed in to change notification settings - Fork 1
Momentum & Physics
The best way to design a realistic momentum system (or almost any other physics system) is simply to look at how it works in the real world. If you copy the physics of real life, even in a somewhat simplified form, it is difficult to produce something that feels particularly unrealistic without purposefully trying to. There were a number of real-life mechanics that we wanted to implement, namely:
- Smooth acceleration and deceleration curves
- Some sort of speed limit
- A feeling of 'weight' and momentum
In the real world, acceleration curves are a complex topic with many factors. However, these factors all essentially affect three variables: the coefficient of friction, the weight of the object, and the force exerted. Aerodynamic improvements and changes in material are all friction affectors, and things like engine modifications or better traction are force improvements. Weight is self-explanatory, and for the most part static. These factors fit together in two competing equations:
Acceleration (a = F / m)
Friction (f = μ * nF)
Where:
- a is the acceleration of the body
- m is mass of the body
- F is force applied to the body
- f is the force of friction experienced by the body
- μ is the coefficient of friction
- nF is the normal force of the body (the force it is already under in the direction of motion)
These two equations compete to produce various different movement phenomena. As the strength of friction increases with movement speed but the acceleration does not, it naturally produces a curve of diminishing speed returns and an upper limit, satisfying the first two requirements. As the player only slows due to friction they will not instantly stop when force is no longer applied, therefore satisfying the final requirement of momentum.
This game uses the libGDX engine, which contains a physics engine capable of simulating these physical phenomena. The player entity is a physics object with mass, movement vectors, and functions such as applyForce()
which can be used to manipulate it. Therefore the simulation of momentum is simplified from implementing the physics equations and mechanics to simply determining the force vectors which can then be fed to the engine, as well as maintaining some constants. In the case of equation 1, acceleration, this is trivially accomplished by simply using applyForceToCenter()
in the direction of the player's movement, scaled by their acceleration constant. This occurs in the updateSpeed()
function.
Equation 2, friction, must still be implemented in full as it calculates the force, however this is also rather simple. The applyFriction()
function firstly obtains the player's current linear velocity, which is equivalent to their normal force, and then creates a new vector which represents the inverse of their linear velocity multiplied by the coefficient of friction. In short, it simply applies the above friction equation, inverting the output in order to point the vector in the correct direction. This is then fed to applyForceToCenter()
, smoothly slowing the player.
Both of these functions execute every update()
, in order to ensure that the physics remains consistent even if any outside forces are applied to the player.
Testing Plans
Team 1
Team 2
Team 3
Team 4
Team 5
Team 1
Team 2
Team 3
Team 4
Team 5
User Testing
Sprint 1 - Game Audio
Sprint 1 - Character Design
Sprint 1 - Menu Assets
Sprint 1 - Map Design
Sprint 1 - Void
Sprint 2 - Game Audio
Sprint 2 - Character Design
Sprint 2 - Menu Assets
Sprint 2 - Interactable Design Animation
Sprint 2 - Levels 1 & 4, and Level Editor
Sprint 2 - Proposed Level 2 & 3 Designs
Sprint 2 - Current Game State
Sprint 3 - Menu Assets
Sprint 3 - Map Design
Sprint 3 - Score Display
Sprint 3 - Player Death and Spawn Animations
Sprint 3 - Pick Ups and Pause Screen
Sprint 4 - Gameplay
Sprint 4 - Game UI and Animation
Sprint 4 - Level Background and Music
Sprint 4 - Game User Testing
Sprint 4 - Final Game State Testing
Entities and Components
Status Components
Event System
Player Animations Implementation
Development Resources
Entities and Components
Level Editor (Saving and Loading
Multiple Levels)