Skip to content

Momentum & Physics

Ari Bowe edited this page Sep 1, 2021 · 3 revisions

Momentum & Physics

The Real-World Basis

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.

How This Translates to a Game

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.

Table of Contents

Home


Game Design

Game Design Document

Void/Antivirus

Loading Screen

Game Sound

Menu Assets

Player Design

     Original Design

     Final Design


Gameplay

Movement

Jumping & Sliding

Jump Pads

Portals & Bridges

Buttons

Pick-Ups

Physics

    Momentum & Physics

    Gravity

    Collision


Level Design

Level 1

     Background

     Textures

     Map Design

Level 2

     Background

     Textures

     Map Design

Level 3

     Background

     Textures

     Map Design

Level 4

     Background

     Textures

     Map Design


Sprint Round-Up

Sprint 1 Summary

Sprint 2 Summary

Sprint 3 Summary

Sprint 4 Summary


User Testing

Testing Plans

Sprint 1

     Team 1
     Team 2
     Team 3
     Team 4
     Team 5

Sprint 2

     Team 1
     Team 2
     Team 3
     Team 4
     Team 5

Sprint 3

     Team 1
     Team 2
     Team 3
     Team 4
     Team 5

Sprint 4

     Team 1
     Team 2
     Team 3
     Team 4
     Team 5

User Testing

Sprint 1

     Sprint 1 - Game Audio
     Sprint 1 - Character Design
     Sprint 1 - Menu Assets
     Sprint 1 - Map Design
     Sprint 1 - Void

Sprint 2

     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

     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

     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


Game Engine

Entities and Components

     Status Components
     Event System
     Player Animations Implementation

Level Editor

Level Saving and Loading

Status Effect


Defunct

Development Resources

    Getting Started

Entities and Components

    Level Editor (Saving and Loading
         Multiple Levels)

    Service Locator

    Loading Resources

    Logging

    Unit Testing

    Debug Terminal

Input Handling

    UI

    Level Saving/Loading

    Status Effects

    Animations

    Audio

    AI

    Physics

Game Screens and Areas

    Terrain

    Concurrency & Threading

    Settings


Troubleshooting

MacOS Setup Guide

Clone this wiki locally