Class PositionSyncComponent

java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.components.PositionSyncComponent

public class PositionSyncComponent extends Component
A component that synchronizes the position and velocity of this entity with a designated "host" entity, maintaining a fixed offset from the host.

This is useful for entities that should follow or remain attached to another moving entity, such as platforms or carried objects.

  • Constructor Details

    • PositionSyncComponent

      public PositionSyncComponent(Entity host)
      Creates a new PositionSyncComponent that will follow the given host entity.
      Parameters:
      host - the entity to synchronize position with
  • Method Details

    • create

      public void create()
      Description copied from class: Component
      Called when the entity is created and registered. Initial logic such as calls to GetComponent should be made here, not in the constructor which is called before an entity is finished.
      Overrides:
      create in class Component
    • update

      public void update()
      Description copied from class: Component
      Called once per frame of the game, and should be used for most component logic. Not called if component is disabled.
      Overrides:
      update in class Component