Use this augmented reality tutorial for using Vuforia SDK to build a simple Pokemon game.
This post is an augmented reality tutorial for Vuforia SDK. Follow along to build your own simple Pokemon game. Before proceeding further, you must be familiar with Vuforia SDK, with a database to use in Unity. If you haven't done that, go through the Vuforia tutorial and learn to build a database on Vuforia. Download it as per the instructions in that tutorial.
To Augment a Pokemon, you will need a Pokemon 3-D model. Download the Pokemon 3-D models.
Choose any 3-D model and download it—easy and simple. So, now we have the following:
- Vuforia SDK
- Image target database
- 3-D models
Open Unity and create a new project. Import the Vuforia SDK and image target database into Unity.
You can do that by navigating to Assets > Import Package > Custom Package. Locate the .UnityPackage file in the dialog.
For 3-D models, drag and drop the whole folder in Unity.
Now, in the hierarchy window at 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. Navigate to Vuforia > Prefabs to find them. Drag them into the hierarchy window.
Then, select "AR Camera", and, in the inspector window, select "Add License Key", which we created in the last Vuforia SDK tutorial. You can see it in the image circled below.
Awesome work! Save the scenes in the file options.
Now, select "Image Target" from the hierarchy window. Select the database and image from the 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 Iwill be setting the Pokemon on top of it, as you can see further below.
Next, Navigate to the Pokemon 3-D model folder. It should look like this, except for the fact it might be a different Pokemon.
Select the .obj file and drag it inside the image target in the hierarchy window.
You will notice that the 3-D model size is larger than the image target. You can change the size of the model from the inspector window by changing the scale.
You can see that 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 the 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 in front of the webcam, and you can see your 3d model.
Or, you can also deploy it on your app.
That's an easy step. Navigate to File > Build and Run . Switch it to the 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 to locate 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, please check out my other VR and AR tutorials
. This is how the finished product looks:
I hope you were able to build your first game using this augmented reality tutorial. Keep following me for more easy tutorials on augmented reality and virtual reality. You can also connect with me on our online channel in Slack to get more guidance.