How to Make an Augmented Reality Pokemon Game using Vuforia!
From our Virtual and Augmented Reality Leader: Sanket Thakur
This post is an Augmented Reality tutorial for using Vuforia SDK to build a simple Pokemon game. Before proceeding further, I hope you must be ready with Vuforia SDK and a database to use in Unity. If you haven’t done that go through the Vuforia tutorial, to learn to build a database on Vuforia and download it as per the instructions on that tutorial.
Augmented Reality Tutorial for building a Pokemon Game
To Augment a Pokemon, you will need a Pokemon 3d model. You can download Pokemon 3d models from here.
Choose any 3d model and download it. Easy and simple. So, now we have :
- Vuforia SDK
- Image Target Database
- 3d models
Open Unity, create a new project. Import the Vuforia SDK and Image Target Database into Unity.
You can do that by : Assets > Import Package > Custom Package. Locate the .UnityPackage file in the dialog.
For 3d models, Drag and Drop the whole folder in Unity.
Now, in the hierarchy window at extreme left. You will notice two items – Main Camera and directional light. We will not require Main Camera for the project, so you can Delete Main Camera. Instead we will need an AR camera and Image Targets. You can get them in Vuforia > Prefabs folder. Drag them in the hierarchy window.
Then, select AR Camera and in the Inspector Window. Add License Key – which we created in the last tutorial in the space provided for it. You can see it in the image circled around.
Awesome work! Save the Scenes in the file options.
Now, Select Image Target from Hierarchy window. Select the database and image from Image Target. (I have imported two databases that’s why two database options are showing). Here, I am using the keyboard of my laptop as the image target, and will be setting the pokemon on top of it as you can see further below.
Next, Browse to the Pokemon 3d model folder. It should look like this except for the fact it is for different Pokemon.
Select the .obj file from it and drag it Inside the Image Target in the hierarchy window.
You will notice that 3d model size >> Image target. You can change the size of the model from the Inspector window by changing the scale.
You can see in the image I reduced the scale from 1 to 0.05. You can also rotate the model by playing with the rotational values.
Important Step: Finally, you will need to load the databases to AR Camera. Select AR Camera. In the Inspector window, check the options for Load Object Target , Load Database and Activate.
You can try the app by pressing the play button above the scene window. You will need a webcam to use it. Focus the image infront of webcam and you can see your 3d model.
Or, you can also deploy it on your app.
That’s an easy step. File > Build and Run . Switch to Android / iOS platform.
Note: Don’t forget to change the Bundle Identifier in Player Settings. You can change it to anything.
That should build your app in your phone.
If this is your first time with Unity, it will ask you for locating the Android SDK folder. Download the Android SDK and locate it while building the app in Unity. If you have doubts or if it is the first time you are trying out an augmented reality tutorial, check out my other tutorials on Unity and Vuforia here. This is how it looks like finally:
I hope you were able to build your first game using this augmented reality tutorial. Keep following me for more such easy tutorials on Augmented Reality or Virtual Reality. You can also connect with me on our online channel in slack to get more guidance and check out my learning path to become an expert.
-From our VR-AR Leader: Sanket Thakur
Sanket Thakur is the Leader in Virtual and Augmented Reality Technologies at DIY Hacking. He has created several applications for the platforms and is aspiring to pursue research on the same.
Contact: [email protected]