Quantcast
Channel: Yudiz Solutions Ltd.
Viewing all articles
Browse latest Browse all 595

Create your First VR Game using Unity, Check Our Simple Demo Code !

$
0
0

Introduction

Currently, the most popular option for developing VR games is Unity. Google CardBoard comes as the prime choice to get started rather than spending plenty. Loads of people having smartphones can enjoy your game on a lesser expense.

The core purpose of this tutorial is to describe how to integrate Cardboard SDK with Unity.

Setup for Cardboard SDK

With this SDK and Unity, you can create virtual reality applications in Android as well as iOSthat runs in Google cardboard.

  • Here is the link for CardboardSDKForUnity: Link
  • Here is the link for CardboardDemoForUnity: Link

How to import and preview the demo scene SDKs Package?

Follow 3 simple steps below to import and preview the demo scene SDKs Package :

  1. Open Unity
  2. For SDK package, go to Assets -> Import Package -> Custom Package.
  3. For Demo Package which is a default demo game, go to Assets -> Import Package -> Custom Package.

How to build a demo ?

Follow the below steps to build a demo :

  1. Go to File, select Build Settings and then select Android as your platform.
  2. Click Player Settings. Under “Other Settings”, enter a package name into the “Bundle Identifier” field (for example, com.example.CardboardUnityDemo). Under “Resolution and Presentation”, check if the default orientation is set to “Landscape Left”.
  3. Click on Build and Run.

Create a game Scary Hospital

Please follow the below instruction and build your own game !

1. SetupCamera

  • Select prefab CameraMain from Cardboard from Assets.Then simply drag and drop into inspector.Later on, you can adjust camera position according to your viewpoint.
  • Now run the project to see how your model looks in game Mode.

It will look similar to the picture shown below:

vr-thumb-1

In playMode, you can move camera using Alt and moving mouse. It will help you see like how things look in vr.

2. Interact with UI

  • One thing we have to consider is UI must be replicated in each eye. So we have to place in virtual space to focus.
  • Create canvas and set it to worldspace.
  • To accomplish this, add the GazeInputMobile script to scene Eventsystem.

3. Creating Reticle

We need a particular pointer to aim something like clicking buttons, hovering.

vr-thumb-2

You can create this by Select a prefab from Cardboard, go to UI and select CardBoardReticle Script into CardBoardMain game object in inspector. Make sure its parent is MainCamera.

vr-thumb-3

This prefab has attached Script named CardboardReticle which has 2 properties as:

  • Reticle Segments: Number of segments making reticle circle.
  • Reticle GrowthSpeed: Growth speed multiplier for the reticle when we aim into UI.

vr-thumb-4

Now, you can hover on UI and can click buttons.

You can make many stuff with the help of this. Currently in my demo , if I hover on Alien for 3 seconds, it will die!

vr-thumb-5

Check Our Demo Here: Download Dropbox Link

Now you can develop your own game referring the demo dropbox link given above and feel free to use it. This article would be a perfect pick to developing VR games describing an easy and trouble free way working with Google CardBoard and Unity. As always, please comment below.


Viewing all articles
Browse latest Browse all 595

Trending Articles