-waypoints-

Description

This asset was designed as a means to speed up projects where AI characters are to traverse / patrol pathways. This asset comes equipped with a feature that automatically creates subsectors based on user preferences or utilizes preexisting subsectors. Additionally, the asset can determine the best path in O(n2) runtime (much faster and more efficient than the TSP algorithm) to ensure runtime is low, allowing users to connect POIs seamlessly. Users can also choose to render a line-based path for easy visualization. The asset's AI characters are capable of identifying the best path based on distance and type. With these features, a user could design a map, name the sectors, drag, and drop a POI component on any structure that should be tagged as a point of interest and let the algorithm do the rest.

How to use

  • Import the Package into the Project.
  • Drag and drop POI component on points of interest in your scene.
  • Group subsector POIs under an empty gameobject and place a subsector component on that object.
  • Group subsectors in an empty gameobject and place a sector component on that object
  • More details bellow

Technical Details

Map

  • Sectors: The speed variable controls the player's movement speed, allowing them to move faster or slower across the playable area based on the Speed value.
  • Subsectors: If directional rotation X is true and directional rotation Y is false, the player will rotate up to -(Max Rotation Angle) while moving left, and up to +(Max Rotation Angle) while moving right.
  • POIs: If "return to original rotation" is true, the player will rotate back to (0,0,0) once the joystick is no longer receiving input. Return rotation speed controls the speed at which the player will rotate to (0,0,0).
  • AI Patrol Behaviour: If this variable is set to true, the player will rotate back to (0,0,0) once the joystick is no longer receiving input. If set to false, the player will maintain its rotation.

Pathfinding

  • Auto-create subsectors based on the number of POIs - If the option is selected.
  • Auto Generate pathways.
  • Algorithm to find the shortest path in O(n^2) time (to ensure good runtime).
  • 2 types of paths, one for all POIs within each subsector, and one for all POIs within a sector.
  • AI will automatically find and patrol the path closest to its location with the matching type.

Other

  • Visualization scripts.
  • Draw line renders to display paths.
  • Camera follow AI to show behavior.
  • Manager with UI elements to show behavior and test scenarios.

How to use [details]

POIs

while setting up project Prefabs, drag and drop a POI component on any structure or other prefab that should be marked as such. This could be any gameobject or transform including an empty gameobject.

Subsectors

if the user chooses to auto create subsectors, this step is not necessary, however, if a user would like to define subsectors, group a block, street, area… under an empty Gameobject and drag and drop a Subsector component on this object. Ensure that all POIs belonging to that subsector are included in the empty gameobject.

Sectors

In order to set up sector object, group all subsectors of one region under an empty gameobject. Drag and drop a Sector Component onto the empty gameobject. If the user would like to auto create subsectors, some more set up is required. Otherwise, the sector object is ready to go. Check Auto find pathways to true if you would prefer the algorithm to determine the pathways, otherwise, uncheck Auto find pathways.

In the case that the user would like to use the auto create option, set the desired Sector POI length to a value of your choice. And make sure to create empty GameObjects that act as Min and Max points of your sector. Create at least 2 points and set them to the maximum (x,y) position of the sector and the minimum (x,y) position of the sector. If these points do not exist the program will default to -250, 250.

Pathways

the program requires a pathway gameobject to hold data of paths, if this does not exist in the scene, the program will automatically create one

AI Patrol System

Any enemy that should be patrolling the scene should have a AIPatrolSystem component attached to it. This will allow it to find the closest pathway to it and start patrolling it. Default pathway type is “Subsector” where the AI will patrol within the borders of a subsector. Other options include “Sector” where the AI will patrol every POI in the entire sector.

Manager

The Manager is only there for debugging and viewing purposes. User will be able to view generated paths by enabling them through UI. The user will also be able to toggle between Map overview or follow AI characters as they patrol the POIs. Removing this component from the game will have no effect and the game will continue to operate without it.