Basic Player Tracking Feature - UQcsse3200/2023-studio-2 GitHub Wiki
Overview
The Basic Player Tracking feature enables the companion entity to perform basic movement on the map while maintaining a certain distance from the player entity. This movement is achieved through the implementation of the CompanionActions component, which governs the companion's behavior. The main goal is to create a dynamic movement pattern that keeps the companion entity close to the player while preventing it from crossing over a designated point on the map.
Usage
Constructor
CompanionActions companionActions = new CompanionActions();
Methods
void walk(Vector2 direction): Moves the companion in a given direction.
void stopWalking(): Stops the companion from walking.
void setPlayerEntity(Entity playerEntity): Sets the player entity reference for the companion.
void update(): Updates the companion's movement and speed based on user input.
boolean isMovementKeyPressed(): Checks if any movement keys are pressed.
void updateFollowPlayer(): Updates the companion's position to follow the player.
void updateSpeed(): Updates the companion's movement speed.
void create(): Initializes the companion's behavior and event listeners.
Dependencies
PhysicsComponent: Manages the physics simulation of the companion entity.
Entity: Represents the companion entity and facilitates interactions.
Vector2: Provides vector operations for position calculations.
ServiceLocator: Manages game resources and services.
Implementation Details
The Individual Movement with Rotational Component feature introduces a more advanced movement system for the companion entity. The walk() method allows the companion to move in a given direction, providing a greater degree of control over its movement. The stopWalking() method halts the companion's movement, ensuring smooth and controlled navigation.