Skip to content

FollowEntity

Maxwell Schroder edited this page Sep 13, 2023 · 1 revision

Description

A component to make one entity follow another.

Usage

Constructor

CompanionActions companionActions = new CompanionActions();

Methods

void FollowComponent: Set up the following speed and the entity that this entity is following

void setFollowSpeed: Given a speed, adjust the following speed of the entity

void update: Checks if companion is being moved. If it isn't, call MoveEntityTowardFollowingEntity

void moveEntityTowardFollowingEntity: Move the entity towards the following entity

Dependencies

PhysicsComponent: Manages the physics simulation of the companion entity.

Entity: Represents the companion entity and facilitates interactions.

CompanionActions.isCompanionBeingMoved: Represents a bool which reveals if the entity is being moved or not

FollowEntity Making sure that there actually is an entity to follow

ServiceLocator: Manages game resources and services.

Implementation Details

The follow component is currently configured for companion. It listens to the movement variable of the companion (seeing if it is being controlled). If the companion is not moving on its own, it is drawn towards the player. This helps keep the companion close to the player, and not fall outside of the screen.

UML Diagram

None

Clone this wiki locally