Skip to content

Dactarium/Waypoint-System

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Waypoint System

Unity Waypoint System for NPCs, Vecihles and etc.

Index

Getting Started

Download "WaypointSystem.unitypackage" and import to unity

Creating new waypoint

Open Tools/Waypoint Editor

image

Press Create New Waypoint Root

image

Press Create Waypoint Button

image

Selected Waypoint Utilities

image

Button Description
Create waypoint from selected Creates new waypoint and connects selected waypoint
Remove selected waypoint Removes and disconnects selected waypoint

Selected Multiple Waypoints Utilities

image

Button Description
Connect to New Waypoint Creates new waypoint and connects selected waypoints
Connect Selected Waypoints Connects selected waypoints eachother
Disconnect Selected Waypoints Donnects selected waypoints eachother
Remove Selected Waypoints Removes and disconnects selected waypoints

Ps. Make sure Waypoint Selection is True

Usage On Script

Waypoint Class

Public Values

    Radius (get/set): Radius of Waypoint. It affects Random Position.
    Connections (get): Returns connections of waypoint.
    LeftBound (get): Returns left bounds world position of waypoint.
    RightBound (get): Returns right bounds world position of waypoint.
    RandomPosition (get): Returns Random world position in radius of waypoint.


Set (Waypoint waypoint)

Sets other waypoints radius and connections to waypoint

waypoint.Set(other);

Connect/Disconnect (Waypoint waypoint)

Adds or Removes Waypoint from Connections

waypoint.Connect(other);

You should use Has method before using and you should write otherWaypoint.Connect(waypoint);

waypoint.Disconnect(other);

You should write otherWaypoint.Disconnect(waypoint);


Has (Waypoint waypoint)

Checks is waypoint in Connections and returns bool value

waypoint.Has(other);

FindConnectionsWithTag (string tag) & FindConnectionsWithName (string name)

Finds Connections with tag or name and returns list of waypoint

waypoint.FindConnectionsWithTag(tag); // If there is no connection with tag returns null
waypoint.FindConnectionsWithName(name); // If there is no connection with name returns null

WaypointNavigator

Navigate (Waypoint start, Waypoint destination)

Finds route for start to destination waypoint with A* Pathfinding Algorithm and returns stack of waypoint.

WaypointNavigator.Navigate(waypoint, other);

WaypointRoot

FindWaypointsWithTag (string tag) & FindWaypointsWithName (string name)

Finds child waypoints with tag or name and returns list of waypoint.

waypointRoot.FindWaypointsWithTag(tag); // If there is no connection with tag returns null
waypointRoot.FindWaypointsWithName(name); // If there is no connection with name returns null

GetNearestWaypoint (Vector3 pos)

Returns nearest waypoint given position.

waypointRoot.GetNearestWaypoint(position);

GetFarestWaypoint (Vector3 pos)

Returns nearest waypoint given position.

waypointRoot.GetFarestWaypoint(position);

Credits

I learned how system works from Game Dev Guide's Building a Traffic System video.