Skip to content

Entity physics #357

@caelunshun

Description

@caelunshun

Implement entity physics: gravity and collisions with blocks.

The basic algorithm for Minecraft entity physics is, each tick, to:

  1. Add velocity to position.
  2. For each axis (X/Y/Z) individually, check for collisions between the entity's bounding box and blocks. If there are any, clamp the entity's position to the edge of the block. There are some useful details on collision detection here, there I'm sure there are better sources.
  3. Apply gravity to velocity.
  4. Multiply velocity by a drag factor.
  5. For certain entities, steps 3 and 4 are swapped.

In Minecraft physics, different entities behave differently with different drag/gravity forces. This parameters are listed here. To implement this in Feather, we would use a Physics component containing a field for each parameter: gravity_acceleration, drag_factor, bounding_box, and drag_before_acceleration: bool.

Some further guidance on implementing this: The Physics struct should be defined in feather-common, as should a physics_system that uses a query to iterate over all entities with Physics, Position, and Velocity components.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions