Package ecs

Class CollisionHandler

java.lang.Object
ecs.Component
ecs.CollisionHandler
All Implemented Interfaces:
Comparable<Component>

public abstract class CollisionHandler extends Component
A component to handle and react to collisions using a collider. Can be attached to an object if it should react to collisions in any way.
Since:
07.12.2021
Author:
Juyas
See Also:
  • Constructor Details

    • CollisionHandler

      public CollisionHandler(Collider collider)
  • Method Details

    • start

      public void start()
      Description copied from class: Component
      Called once on Component initialization.
      Overrides:
      start in class Component
    • update

      public void update(float dt)
      Description copied from class: Component
      Called once per frame for each Component
      Overrides:
      update in class Component
      Parameters:
      dt - Engine.deltaTime
    • getCollider

      protected Collider getCollider()
    • collision

      public abstract void collision(Collider environment, CollisionInformation collisionInformation)
      Will be called in the update loop if a collision happens CollisionInformation.collision() with the given environment collider and the defined one of this handler {@link this#getCollider()}.
      Parameters:
      environment - the other collider in the environment
      collisionInformation - the data about the collision