Unity Waypoint System for NPCs, Vecihles and etc.
- Getting Started
- Creating new waypoint
- Selected waypoint utilities
- Selected multiple waypoints utilities
- Usage On Script
- Credits
Download "WaypointSystem.unitypackage" and import to unity
Open Tools/Waypoint Editor
Press Create New Waypoint Root
Press Create Waypoint Button
Button | Description |
---|---|
Create waypoint from selected | Creates new waypoint and connects selected waypoint |
Remove selected waypoint | Removes and disconnects selected waypoint |
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
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.
Sets other waypoints radius and connections to waypoint
waypoint.Set(other);
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);
Checks is waypoint in Connections and returns bool value
waypoint.Has(other);
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
Finds route for start to destination waypoint with A* Pathfinding Algorithm and returns stack of waypoint.
WaypointNavigator.Navigate(waypoint, other);
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
Returns nearest waypoint given position.
waypointRoot.GetNearestWaypoint(position);
Returns nearest waypoint given position.
waypointRoot.GetFarestWaypoint(position);
I learned how system works from Game Dev Guide's Building a Traffic System video.