Introduction
This blog is about implementing the Mapbox SDK for the Unity project. This is a step-by-step guideline for Unity developers to integrate Mapbox SDK into games.How the Mapbox Maps SDK works
The Mapbox Maps SDK for Unity is designed to help Unity developers add dynamic map data to their games and applications by providing a straightforward programmatic and graphical interface to Mapbox's web services APIsHow to Start
To install the latest Mapbox SDK click hereCreate a new project in the Unity editorSet Access Token
Create an account using this linkCopy your access tokenSetup access token in unityPast your access token and click on Submit button to check if it is valid or notNow we are all set to integrate different types of map gamesLocation Based GameThe location-based shows how to position and orient a Player GameObject on a map using a GPS device or using the editor directlyThere are two location-based game example scenes inside of the SDK: Location-based game and Astronaut gameBoth scenes use the LocationProvider. Which will automatically use the device's GPS to position the game mapTo use LocationProvider we just need to drag and drop the LocationBasedGame prefab game object into the sceneThe LocationProvider game object shows the player’s location, either in the real world or in the unity simulator. Without LocaionProvider scripts location would be hard coded in the AbstractMap scriptDeviceLocationProvider: It uses GPS data on the device. The player game object follows the location on the map which is provided by the GPS device updateEditorLocationProvider: It is similar to DeviceLocationProvider, but its works in the editorLocationArrayEditorLocationProvider: It allows the player game object to move across a set of points entered as latitude and longitude coordinates in an arrayTransformaLocationProvider: It helps the player game object to follow the position and rotation of other game objectsDeviceLocationProviderAndroidNative: It uses the GPS data to optimize for Android devicesUsing the Location based game example, we can create a pannable, zoomable map that a player can move around on itCustomize map
Create a map of New York, USASelect the Map object at the inspector window. Under the AbstractMap general settings, either change the location to 40.7306, -73.9866 or search “New York”Enable Preview so we can see current changes in the game sceneNow open the Image settings and change the Data Source to “Mapbox Satellite Street”Now open the Terrain settings and change the Elevation Layer Type to “Flat Terrain”If you have any questions regarding Unity Game Development Services Connect with us today!
Sign in to leave a comment.