-
Notifications
You must be signed in to change notification settings - Fork 7
Map_Directions
Using locations in games is a great way to give the player a sense of freedom! However, for more complex paths or perhaps just to offer a more user friendly experience directions can be a handy resource to offer players.
As such, LUTE offers some simple directions using the Mapbox navigation API. You can find an example within the project simply called 'LUTEDirections'.
Adding directions to your game is rather simple! All you need to do is ensure that your scene contains the LUTEDirections prefab object.

The object contains a class called LUTEDirectionsFactory. This class handles drawing directions between a list of provided points. You can modify the visuals of the path drawn by replacing or adding to the list of Mesh Modifiers (which are essentially a way to draw an object based on a list of points on a path). You can also replace the Material on the class so that when the path is drawn it is custom to your theme.
Within the demo scene we have included two waypoints (under the main direction object). These waypoints are included in the default list of points for the directions to be drawn and can be dragged around using most input systems. Have a go at playing the scene and moving the pins then watch the path get redrawn!

If you are intending for the player to follow a route similar to other map services then we suggest ensuring that Query With Map and Query With Time are active on the direction object. This ensures that anytime the player moves the path gets updated; Mapbox uses a specific method to query the most optimal path and we have chosen to 'Walking' as the default method of transportation (as we do NOT advise playing a game and driving!)

However, if you wish to simply draw a path once and not update it during runtime then simply turn these options off.
You can use Orders to draw a path between a list of points during runtime. This is useful for when a player reaches a specific location and then is stumped on where to go next.
The Add Direction Waypoints Order allows you to build a list of location variables for a path to be drawn for. You can even start the directions directly from the player position! This Order will remove all waypoints from the current direction handler and then create a new list with the provided locations. You can even change the Mesh Modifier and the Material for further customisation.

You may also wish to remove a path if a player reaches another location or completes the game. You can do this easily by using the Clear Direction Waypoints Order.

This will clear all the waypoints from the directions handler and thus remove the path from the map!
Have a go at adding directions using Orders or through the modifying the object in the scene directly. If you are using the Waypoints provided then please ensure you correctly set all fields (this goes double for the Direction hanlder object!)