Week 4 - Tutorial


I made a few changes to the scene I made last week in order to better implement a new feature: the Navigation Mesh. Up until now, I have been controlling the little character, making him walk around the scene and occasionally wave to the camera. But now there are enemies that can pursue the player around the scene! In order for these enemies to properly navigate their way around the terrain and through obstacles, they must first know exactly where they can and can't walk. This is the basic concept behind a Navigation Mesh; in accordance to the settings you define beforehand, it will determine what parts of the world are navigable or not. The mesh itself can be thought of as a sort of layer of paint which has been applied to the desired parts of the world, which Agents are then restrained to whilst moving around. An Agent is simply a term which refers to something which utilises and obeys the constraints of a Navigation Mesh, which in this case are the enemies.


You may also notice that enemies only appear when I click somewhere in the world - this is being done through Raycasting. A Raycast is simply a line which starts from a  given point and continues infinitely in a particular direction (unless a distance limit is specified). This line can intersect any number of objects in the world, and can even store those objects along with the coordinates at which the collision took place. In this case, every time I click, a ray is being cast from the camera's position to where the mouse is positioned inside the world (keeping in mind that the position which the mouse occupies on the screen needs to be translated into a position inside the game world). This ray could potentially intersect any number of objects, but here we only want the very first object which it collides with - which should hopefully be some part of the ground. The coordinates of this collision are then used to create an enemy object at that position.

Leave a comment

Log in with itch.io to leave a comment.