https://github.com/plyoung/WaypointMaker
This is a simple tool for laying out and using waypoints in Unity
https://github.com/plyoung/WaypointMaker
Last synced: 23 days ago
JSON representation
This is a simple tool for laying out and using waypoints in Unity
- Host: GitHub
- URL: https://github.com/plyoung/WaypointMaker
- Owner: plyoung
- License: unlicense
- Created: 2017-08-29T08:58:24.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2021-11-30T19:03:25.000Z (over 3 years ago)
- Last Synced: 2024-11-10T19:33:23.391Z (6 months ago)
- Language: C#
- Size: 42 KB
- Stars: 34
- Watchers: 3
- Forks: 6
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# WaypointMaker
This is a simple tool for laying out and using waypoints in Unity. It also features an option to quickly lay out a simple grid of connected nodes or a street type grid layout of nodes.
### Use
Add `Component > Navigation > WaypointMaker Path` component to a GameObject.
Now you can hold `Ctrl+Help` and click in the scene to add nodes to the scene. You can select an existing node in the scene and then click on another while holding `Ctrl` to make a link from the one node to the other.
Hold `Shift` and drag over several nods to select them all. Use the movement gizmo to move selected nodes. Use `Del` to delete selected nodes.
### Example
The sample scene shows the use of a grid of nodes and includes path finding in the `vehicle` component (script) to show how you might possibl use and navigate the grid of nodes.
### Code
The `Path` component simply holds a list of all the nodes. To find a node (PathNode) you may use `Path.GetNode(node_id)` where `node_id` would be the same as the `id` presented in the Inspector when you have a node selected.
The `PathNode` has the node's `id` and `position` information. It also has a list of node IDs in `outNodeIds`. This list tells you what links this node has towards other nodes. Note that this is a list of IDs, not indices into the list of nodes in the `Path` object. So to get the actual node you would still use `Path.GetNode()`.
There is however also a list of indices generated at runtime during Path's `Awake()`. This is stored in `PathNode.OutNodeIdx` for each node and could be used as a faster way of getting node info than using the ID lookup.
The node ID will never change, even if you add or remove more nodes to the path. The IDX will differ depending on how many nodes are in the scene and in what order they appear in the `Path.nodes` list.
