Tuesday 8 November 2016

Interactivity and Movement

Implementing interactivity and movement

Creating waypoints

Retracing the path

In order to produce way-points for the AI to follow, the path needs to be defined by the pathfinding algorithm and then be turned into a usable format for the AI. To do this, we need to add a parent variable for each node, so we can retrace the path from the origin. We then reverse the path so it is in the correct order, going from start node to end node. The path of nodes is then converted into a list of positions, so the AI can then take the path and move from position to position. To make the AI go where we want it, we can make it move towards the next way-point using Unity's inbuilt "lookat" function, then move the AI until it is in proximity with the end node; this method is useful if physics are a key component for the game, but could trigger things such as jams and inaccuracies. Later on, we may need to simplify and smooth the path for a more realistic look.

Managing Units

We also need a way to select different and multiple units. We can do this via traditional techniques such as shift-clicking to select multiple units one by one and with a box-select that the player drags; this selects all units within the box. To create this technique we need to convert mouse position to world space and raycast, checking to see if a friendly unit was hit. Camera movement also needs to be achieved; the camera will need to be moved by screen edge-proximity in terms of the mouse as well as keyboard controls. Camera controls will also need to include zooming in and out as well as rotating. The box select method may need to be included by creating a collider and then checking all collided objects for units, however this could be bad for performance if a lot of objects are selected.