Features Tech Discussion(Ship Control, Resources Gathering, Roles)


Ship Control

User will control the units by commands and mouse click. We will use Unity ray cast from screen to world location and use navigation agent to find the path. Units will have a command queue to execute the commands.

- Move: Mouse right click to move the selected units to the target location.

- Attack: Units will attack the enemies on the path, will move to the location if there are no enemies in the path.

Stop: Clear the current command queue. Back to normal states, attack in range enemies.

Waypoints: Create a command queue for the selected units to execute in sequence.

Group Movement

We probably need a UnitGroup class that contains several units, although the group behaves as a single entity:

  • The units within the group always have close goals.
  • There are internal collisions within the units of the group. If any space is left between some of the members of the group, a non-grouped unit can occupy it.

Struct for a group of units

Groups can also have the following properties:

  • Maximum speed at which the group can move while still keeping together: it is determined by the speed of the slowest unit, or the slowest unit moves a little faster when it is in a group or has a temporary speed boost in order to catch up.
  • Centroid of the group: reference point for the group.
  • Commander for the group: unit that does the pathfinding for the group and decides which route the group as a whole takes.

When a unit is ordered to move, it runs through a state-based movement algorithm. The states of the unit’s movement are: 1. Wait for path: if the unit has a valid goal, a path is requested to the Pathfinding module. 2. Follow path: the unit moves from one waypoint of the path to the next one. This state also manages the collision prediction and avoidance for the unit. 3. Goal reached: when the unit reaches its goal, it goes to this state. 4. Increase waypoint: when the unit reaches its next tile, this state updates the next tile with the next waypoint of the path.

StarCraft relies almost solely on the pathfinding algorithm A* to move units from one point to another, mapping every single node that the unit needs to traverse over. In StarCraft II, a lot of the pathfinding is led up to the unit, and waypoints are kept to minimum.

Enum with all of the possible states of a unit’s movement

Reference:

https://sandruski.github.io/RTS-Group-Movement/

Gather Resources

When the engineering ships return to base, the clients will raise an event containing the number of resources gain to the master server, and then the master will synchronize the resources among all the clients.


The different characters

One battle holds 2 commander instances (1 for each sides) and several soldier instances based on the game initializer.

Commanders and soldiers hold an action queue and assign actions to the battle manager by sequence. And have the ability to clear the current queue.

Commander class:

-Property: playerID, Technology slot number, Research speed          

Action Queue:

-Research queue, Construction queue, commander operation queue.

Soldier:

-Property: playerID, Max control number.

-Action Queue: Soldier operation queue.


Get Hoag's End

Leave a comment

Log in with itch.io to leave a comment.