I have completed the scripts required for both movement and unit movement.
The main script for unit selection script, called UnitControl, is used to detect whether an object is a unit controlled by the player through a raycast.
Left-Clicking a player controlled unit will add it to a list of currently controlled units. Left clicking anywhere else will clear the unit list. If another player unit is selected, it will clear the list unless the left shift key is used.
A minor script, called Plumbob, displays a small yellow sphere above all selected units, which is linked to through the PlayerUnit.
Movement for player units is divided into 2 sections; UnitControl and PlayerUnit.
UnitControl calculates the average position of every unit currently selected. When a piece of ground is clicked with the right mouse button, the position clicked will be added to the average position and be sent to the player unit.
The unit has a list of positions it will got to, following a path. Once it reaches a position it will remove that position from the list and the unit moves on to the next one. If the list is empty the unit will set it’s current position as the first position
Movement for enemy units is similar to the players movement, however will be more reliant on Path-finding and auto-targeting
For the enemy and player unit’s path finding i will use the Astar Script (http://arongranberg.com/astar/) i discussed in the first post. I found that i should focus on the game play for the project due to time constraints and other assignments.
I forgot to mention i would be using a tutorial to create the click and drag script, found here: