Demo 01
Demo_01 is a more complex demo which handles different things such as mouse input and previewing the road tiles. This is all handled in the PathGridInputSystem script.
You can of course use the PathGridInputSystem to your liking and modify the code as you like. Please make sure to make a copy of the script first.
PathGridInputSystem - Component
This script - located on the PathGridDemo game object in the scene - handles all the user input as well as checking for the cell type at current mouse grid position.
The PathGridInputSystem can be seen as an example on how to collect path cells positions from the users mouse position and then passing them on to the PathGridSystem (AddPathCells).
What this script do:
When system is enabled, we wait for the users first click (clickCount)
When user has clicked once, we start previewing the mouse grid position by instantiating preview blocks.(PreviewPaths)
The directionLockDistance defines how many cells we should "lock" a direction for the path preview (+x,-x,+y,-y). Every further movement of the mouse is then being previewed in perpendicular direction. like an "L"
If checkForCellTypesOnPathNetwork is enabled, we further check if the currently selected path prefabs cell type matches the path networks cell type. A path network cell type can be defined by using: SetCellTypeAtPosition. Following types can be set: * None * Terrain
* Water
* Blocked
When user clicks the second time we clear the preview blocks and send the collected positions to the PathGridSystem which takes care of building the path.
Right mouse click aborts the preview and resets the click count.
Last updated