Skip to content

Entity physics #357

Open
Open

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.

Activity

  1. lolgeny commented on Mar 6, 2021

    @lolgeny

    I'll try doing this as a first contribution

  2. oxkitsune commented on Mar 6, 2021

    @oxkitsune
    Member

    I think someone was working on this already, @Stoozy. I'm not sure how far they are but maybe you can collaborate?

  3. lolgeny commented on Mar 6, 2021

    @lolgeny

    Oh ok, I'll do something else, I didn't know that

  4. Stoozy commented on Mar 8, 2021

    @Stoozy

    Yea

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

good first issue

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions