A First Person Shooter Game Using Realtime Map Locations

Introduction: A First Person Shooter Game Using Realtime Map Locations

I made this project few months ago(when covid19 lockdown began) and to be honest it was quite thrilling to make something like this from scratch. The idea was to bring real maps into the games and have fun. I ended up building a prototype for the same which I will be covering in shortly.

I'll start with prerequisites installed in your system before I begin

1. Unity game engine (A free student version is available which can be easily downloaded here)

2. Mapbox SDK (I used mapbox as it was readily available and has a free tier as well).

Step 1: Adding Game Component

1. Add a base game component (floor) initially.

Steps: Go to hierarchy panel and create a plane for the game character to reside in.

this floor will act as a reference for the game character and is just a temporary floor and will be replaced with map later

Step 2: Adding a Game Character

Now Adding a game character is quite complicated if you dive in to details (adding motions, animations etc) but thankfully, you can avail the prebuilt ready to use game characters (called assets) from unity asset store.

If your'e really interested there are tutorials on building your game character from scratch on unity learn.

But for now we will go ahead with ready-to-use assets.

Just go to the window tab and click on asset store (it'll require a sign in) or you can go to Asset store , download your favourite asset and import it manually in the project.

From there you can select tons of game characters. For this example I chose "Toon Soldiers WW2 demo" which is free.

Step 3: Configuring Mapbox.

Once the player movement and camera settings are adjusted (Player movements and camera adjustment scripts must be dragged and dropped to the game character prefab), we will begin with replacing our base game component floor (from step 1 ) with a real map.

(I've made camera movements and mouse sensitivity as per my liking. Feel free to tweak the code and change it as per your requirements.)

To add a map you will require a mapbox sdk which can be easily downloaded here.

Then you will need to import this SDK into your unity project by

Assets > Import Package > Custom Package, then select the package file to import.

Once you import mapbox package, there will be an additional mapbox menu item.

Go to Mapbox > Setup and enter Access token which will be generated when you'll sign in to your mapbox account. You can also refer this incase of difficulty.

Once above steps are completed, we can move on to adding real maps into the project.

Step 4: Adding Map Component

Now we have to do is go to Project panel > Assets > Mapbox > Prefabs and drag and drop Map prefab to the hierarchy window into your scene.

Step 5: Customising Map Component

To customise the map component click the map prefab added in the last step.

This will open a inspector pane at the right hand side which will give you multiple options to customise the map.

Just go to General tab and put Latitude and longitude for the desired location.

Once done, go to image settings and change the Data Source to “Mapbox Satellite”.

Finally, open the terrain settings and change the Elevation Layer Type to “Terrain with Elevation”. (This will render a satellite version of the map).

Step 6: Rendering Buildings

However, the building will still be not rendered, to do that,

just go to Map layers tab > Feature >Add feature (select buildings) and hit play.

You'll see the buildings will be rendered now.

You can change the setting for the buildings (scale factor, height, light settings etc by going under building feature ).

completing above steps will build a prototype of a First Person Shooter Game based on real maps.

For reference I have made whole project available on Github

You can check that out here

Feel free to reach out to me incase of any concerns.

Cheers!

Maps Challenge

Participated in the
Maps Challenge

Be the First to Share

    Recommendations

    • Retro Tech Challenge

      Retro Tech Challenge
    • Rocks, Gems, and Stones Speed Challenge

      Rocks, Gems, and Stones Speed Challenge
    • Plastic Challenge

      Plastic Challenge

    7 Comments

    0
    TheDarkOne7
    TheDarkOne7

    1 year ago

    Wow thats awesome

    0
    Vaibhav28
    Vaibhav28

    Reply 1 year ago

    Thanks a lot :)
    This means a lot to me.

    0
    terrefirmax2
    terrefirmax2

    1 year ago on Step 6

    I am concerned about the real life applications...

    0
    Vaibhav28
    Vaibhav28

    Reply 1 year ago

    Hi terrefirmax2,
    The Real life applications of this might not be limited to just games but imagine an API call fetching an entire 3D view of maps to your local machine. From planning cities or using VR to give virtual tours of places as rpitechguy mentioned.

    0
    rpitechguy
    rpitechguy

    Reply 1 year ago

    I mean it's kind of like Pokemon go which is pretty boring but VR would probably be easier especially if you already have a map of your neighborhood...

    0
    InarcoC
    InarcoC

    1 year ago on Step 6

    When I was a child I wondered if one day some computer network would run a videogame in wich you drive over real countries. Ten years after, Streetview came. Now, real maps are being used in flight simulators, car action games... and you are opening the door for realistic indie FPS.

    0
    Vaibhav28
    Vaibhav28

    Reply 1 year ago

    That was the idea behind this project. The main motive was is there a way where we can deliver light weighed applications where game environments can be scrapped off of real life locations. This will add more realistic view to the any game (FPS,RPG etc) youre' playing. Imagine playing NFS on streets of your local address with your neighbour ;)