Jump to content
  • Advertisement
  • entries
  • comments
  • views

Day 37 of 100 Days of VR: Adding Basic VR Changes Into Our FPS I

Josh Chang


Writers Note: Sorry for the lack of updates, I'm not dead yet! I went on a short vacation and got horribly sick. I'm hoping to continue as I have been going before.

Welcome to Day 37! Today, things are finally going to get serious in working with VR!

Currently, there are a lot of problems with the app from when we launch it. Some are just limitations and others are actual problems.

However, before we start to go in and fix everything that we encountered yesterday, today we’re going to add the Google VR SDK into our game.

Today we’re going to:

  1. Set up wireless debugging so we can both: debug and receive console print statements from our game
  2. Remove the old scripts that we’ll replace with VR
  3. Add the Google VR SDK into our game
  4. Set up a simple Event Trigger

Today, we’re going to start working in VR, so let’s not waste time and get to it!

Step 1: Setting Up Wireless Debugging/Consoles

Before we do anything, one of the most important thing we should do is to set up remote debugging or at the very least, the ability to have our console statements be sent to Unity untethered.

Currently, in Development mode, we only get console logs from our Android device if our phone is connected to our computer.

This wire would become too limiting if we must do something like spin around in a circle.

To fix this, we’re going to set up wireless debugging where our phone can send data remotely to Unity.

We’re going to follow Unity’s documentation on attaching a MonoDevelop Debugger to an Android Device.

The instructions are straightforward, so I’ll just leave the link to the instruction.

In our current state, because we have no way of restarting the game, we must rebuild and run every single time we want to see the console wirelessly. The reason being we lost the ability to restart the game inside the game.

However, when we re-add our ability to restart the game, wireless debugging will be more useful.


Step 2: Removing Old Scripts that Needs VR Replacements

It’s finally time to start working in Unity!

Before we do anything, let’s think about the things that the Google VR SDK gave us and what must we get rid of in our current system that conflicts with the VR SDK.

The main thing that the Google VR SDK provides is:

  1. The ability to move the camera with our head
  2. Its own Raycasting system

What we need to remove from our game is:

  1. The ability to move our character
  2. The ability to move our camera
  3. The ability to shoot
  4. The crosshair UI

Luckily for us, this process is going to be fast and easy.

First, let’s remove our ability to move:

  1. In our game hierarchy, select the Player game object.
  2. Select the little cog on the top right-hand corner of the Player Controller (Script) and select Remove Component

Next, let’s get rid of the game following our mouse.

  1. Select Player > Main Camera
  2. Remove our Mouse Camera Controller (Script) Component

After that, let’s get rid of the shooting script. We’re going to come back later and re-purpose this script, but that’s going to be for a different day:

  1. Select Player > Main Camera > MachineGun_00
  2. Disable the Player Shooting Controller (Script) We’re still going to need this.

Finally, let’s get rid of the crosshair. As you recall, when we add the VR SDK, we get a gaze prefab that already adds a cursor in for us.

  1. Select HUD > Crosshair and delete it from our hierarchy.

When we’re done, we’ll have a completely unplayable game! Yay….


Step 3: Adding the Google VR SDK in

Recalling from the Google Cardboard demo, for our game, we’ll need to add:

  1. GvrEditorEmulator – to simulate head movement
  2. GvrEventSystem – to use Google’s Event System for dealing with raycasting
  3. GvrReticlePointer – for our gaze cursor
  4. GvrPointerPhysicsRaycaster – The Raycaster that GoogleVR uses to hit other objects

The set up for this will also be very straightforward.

  1. Drag GvrEditorEmulator in Assets > GoogleVR > Prefabs > GvrEditorEmulator to the hierarchy
  2. Drag GvrEventSystem in Assets > GoogleVR > Prefabs > EventSystem to the hierarchy
  3. Drag GvrReticlePointer in Assets > GoogleVR > Prefabs > Cardboard to be the child of Main Camera
  4. Selectcs from Assets > GooglveVR > Scripts > GvrPointerPhysicsRaycaster.cs and attach it to our Main Camera.

When we’re done, we’ll have something like this:


Now with these prefabs and scripts in, we can rotate and look around our game by holding Alt.

We can also shoot our raycasts with our VR Raycaster, however right now we don’t have an Event Trigger set up in our enemies that will detect them getting hit.

Let’s do that!

Step 4: Setting Up an Event Trigger

Before we end today, I want to make a simple event trigger that allows us to be able to defeat an enemy.

Luckily for us, we already have the function available to us! Specifically, inside our Enemy Health script, we have a code that we call to damage an enemy.

Let’s set this up. We want to get something like this:


For now, we’re only going to change our Knight enemy. Here’s what we’re going to do:

  1. Select our Knight prefab in Assets > Prefab > Knight
  2. Add an Event Trigger Component to our prefab.
  3. Click Add New Event Type to select what type of event we want to listen for
  4. Select PointerClick
  5. Now click + to add the object we want to access the scripts of.
  6. Drag our Knight Prefab into the empty Object slot
  7. Then we need to select the function to call: EnemyHealth > TakeDamage(float)
  8. Set the float value we pass in as 1

When we play our game now, when our gazer focuses on an enemy and we click, we’ll shoot him!

There are a lot of things that we’re missing like the push back, but we can start focusing on the rest of that tomorrow!

Now let’s do that to the rest of our prefabs: Bandit and Zombie!


There we have it! Our first dive into doing some work with VR. It turns out right now, there’s a lot less code that needs to be written, instead, a lot of it is just putting prefabs and scripts to the correct location so our game would work.

Either way, now we have a game that is playable. Tomorrow, we’re going to discuss what changes that we should do to make a better VR experience. Or at the very least, as good as it was before we try to VR-ify it!

Phew, it’s been a long day, I’ll see you all tomorrow on day 38!

Day 36 | 100 Days of VR | Day 38




Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Advertisement
  • Blog Entries

  • Similar Content

    • By Nick Griffith
      I'm making a 2d platformer game as a learning experience, and I need a character and some backgrounds.
      The idea is a person on the brink of death "running" through his memories. The background is his memories.
      This game will make minimal revenue, because it'll be a free mobile game.
      I'll give you more details if you respond.
    • By GameDev.net
      Search GameDev.net directly from the Unity Editor with the GameDev.net Search plugin!
      Customize your search for all content on GameDev.net, only the latest, or the most relevant. Or, narrow your search to specific GameDev.net content:
      Blogs Articles Forums News Contractors Projects and more!
    • By Heretic Arts
      We are an American based videogame development team that crafts games utilizing neural networks, handcrafted art, studio quality audio, and immersive storytelling to provide the player with an unforgettable experience. Our current team comprises of a Software Engineer, Designer, Producer, Audio Engineer, and a systems admin. Obviously we are missing an art staff! Now, that being said, we have outsourced our concept art for the game to an experienced artist. We are wanting talent to join us to take it the rest of the way with animation and art. If you are interested in joining the team and feel that you are ready to work along a committed team, send a sample of your work and contact information to HereticRecruitment@HereticArts.com. 
      Job Specifics: 
      Unpaid. This is normal. We all have fulltime careers outside of the team, but if there is money to be made upon release, it will be split evenly - no questions asked.  All expenses are paid by Administrative Team (GSuite account). So no worries - We want someone to join, have fun and create with us! Expectations of meeting weekly (via internet) and taking direction from producer.  Open minded  
      Skill sets: 
      Experience in designing and creating character art.  Full adobe suite.  Maya experience preferred.  Experience with developing for the Unity Engine.  Willing to work with design team to incorporate their ideas into art.  Knowledge of game design documentation and how it pertains to art creation.  In depth sprite animation knowledge. 
    • By GameDev.net
      GameDaily.Biz spoke to Improbable about its new shortcuts to multiplayer game development for Unity and Unreal. 

      Improbable helps game developers build believable online worlds with its bespoke technology, SpatialOS. Now, that task is much easier and accessible for those building games on the technology with the recent release of the SpatialOS Game Development Kit (GDK) for Unity. With these kits, Improbable hopes that developers find it easier to create vast, dynamic and unique worlds.
      This GDK for Unity includes a 200-gamer, first-person project that allows developers to experiment and tinker with their ideas for what their vision of a multiplayer game will look like.
      GameDaily.Biz met with Improbable’s Head of Product Marketing, Paul Thomas, and Head of Comms, Daniel Nye Griffiths, to speak about the SpatialOS GDK for Unity, as well as the upcoming launch of the SpatialOS GDK for Unreal Engine.
      In its first week, the SpatialOS GDK for Unity achieved over 2,000 developer sign ups to use it. “What we're trying to do is basically make it really fast for people to build multiplayer games,” said Thomas. “It comes with all the multiplayer networking so that developers don’t have to do any multiplayer networking. It comes with feature modules to allow [easy] solutions to common multiplayer problems, like player movement and shooting. And it comes with a cool starter project where you have 200 players in a free-for-all scenario. You can obviously use the power of SpatialOS to scale that project up to more players, with NPCs, and things like that. It gives people a really good base to start building multiplayer games.”
      There are several games currently in development or early access that utilize SpatialOS. The first into Early Access was Spilt Milk Studios’ Lazarus, a space MMO where the player becomes a pilot in a universe that ends every week, complete with a map that’s twice the size of Austria. Additionally, Bossa Studios released its survival exploration game Worlds Adrift into Steam Early Access earlier this year.
      Also using SpatialOS is Scavengers from Midwinter Entertainment, a studio founded by former 343 Industries studio head and Halo 4 Creative Director, Josh Holmes; the game is heavily inspired by his Halo 5: Guardians’ multiplayer mode, Warzone. Right alongside that company, Berlin-based Klang Studios is working on Seed, a simulation MMO that, according to its developers, lets players “interact and collaborate to create a world driven by real emotion and aspiration.”
      According to Thomas, for those looking to use the SpatialOS GDK for Unity, there is no limit to  what their games can do with Improbable’s tech.
      “What we're doing is expanding the possible gameplay you can do. Traditionally, when you make a multiplayer game, you're constrained by one single server. So you can say you have a 64-player game with a handful of NPCs or you could have a world that's 3km by 3km. With Spatial, you can go beyond that, test a much broader canvas to start thinking about different gameplay.”
      “You can go for a massive online persistent MMO with 10,000 players and hundreds of thousands of NPCs, something very, very vast and big like that. But you can also have smaller experiences. For example, there's a lot of interesting space in just extending what you see in the Battle Royale genre and session-based gameplay.”
      Thomas continued: “Our partners at Automaton have a game in development called Mavericks. The interesting thing there is they have a Battle Royale with 1,000 people, but what I really find interesting is the gameplay mechanics they've put in, like footprints so you can track people. They've added a cool fire propagation mechanic so you can start a fire that  spreads across the map and changes the world. Or you can add destructible buildings and things like that.”
      “So I think even looking at smaller scale games, we add a lot of value in terms of the new gameplay you can start adding. I'm just interested to see what people do with this extra power - what they can come up with.”
      While Battle Royale games and MMOs are obvious standouts for genres that best fit with SpatialOS, Thomas introduced some other ideas of genres that could benefit from the technology.
      “I also think there's a space for very interesting MMORTSs as well,” he said. “An RTS where you have persistent systems, like telling AIs to do things and then coming back to them a week later and seeing what's happened is an interesting space.”
      “I also see interesting mobile experiences that could come up. Having these worlds where you lay down some interesting things and then come back a few weeks later to see how they've evolved and changed, and the massive player interaction. Say for example with Pokemon Go, we can actually roam around the world and battle on the streets. I can see something like that working very well. Again, these are just ideas we've had and talked to people about. It's about giving people that flexibility and the ability to explore these ideas.”
      Klang’s Seed
      Griffiths added the possibility of events in a game that will have a massive, rippling, and lasting impact on its world as something that has people excited. One example he gives is how someone on one side of the map can do something that’ll have a knock-on effect for the rest of the world in real time.
      “There's a whole bunch of different angles you can take, some of which are about much larger player numbers or a much larger map, but there are other things you can do which are taking a relatively constrained game experience, a smaller map, a smaller number of players and adding richness to the game as well.”
      In fact, this is something that Thomas refers to as a “persistent in memory database,” meaning that for every object in the game world, there’s a history. Two examples cited by Thomas: “...a player could chop down a tree and that tree stays disappeared forever. Or a player can kill a big monster that was raiding a town and that town no longer gets raided by that monster, and this changes the dynamics of the world. Worlds can have a history. That means players can have a lot more meaning in these MMO worlds.”
      “Normally in MMOs, they're kinda like roller coaster rides: you go into a dungeon, you kill the boss and that guy respawns. It all resets,” Thomas continues. “But in Spatial MMOs, you could have these persistent effects that should change the gameplay meaningfully for all the rest of the player base.”
      “The other one I think that is interesting is the level of dynamism that you could have. So because you can have so much more server-side compute, you could potentially have NPCs roaming around the world changing their mind and deciding all of a sudden, 'oh, we're going to attack this player's base' or 'we're gonna go attack this town' and they have a lot more range and emotion and intelligence to them that you'd not see in other MMOs.
      “Normally in MMOs, NPCs sit there tethered. You go near them and they come and attack you, you run away, and they go back to where they were. In a Spatial MMO, that NPC can trace you across the whole map or a group of them can decide to get together and attack someone..”

      Bossa Studios' Worlds Adrift

      Next week, Improbable plans to launch its SpatialOS GDK for Unreal Engine, which will have a big focus on ease of use for access to Unreal, as well as a big emphasis on porting your projects to SpatialOS.
      “One of the things we'll be trying to push is a porting guide so you'll be able to take your existing Unreal game, move it onto SpatialOS and then you can grow to expand it with new and extra gameplay,” says Thomas. “ You can bring across your existing Unreal game and it feels very, very native and similar to Unreal if you're familiar with Unreal.”
      Griffiths continued, explaining how testing these experiences includes free cloud deployments, to a certain point. “If you're developing in SpatialOS in other ways, we provide a sandbox environment so you can get your game running. When you’re happy, you can port it over and sort of experiment with it in a free sandbox environment with a small number of cores to get started.”
      Based on what we learned, Improbable’s SpatialOS GDK for Unity will give developers enhanced flexibility to produce more in depth and engaging videos games. That said, we look forward to catching up with the company in the near future to see how this exciting technology is being used in the different games that we play.
    • By LonelyStep
      Thought I'd reach out for some feedback on my little project. This is an android two-player game for top-down boxing matches. The core mechanics are all that I have accomplished thus far, later I want to add different configurations for your boxer (special effects, increased health or damage, etc) and maybe even a single player AI to practice against.



      Right now the gameplay feedback I'm looking for is on the fundamental mechanics of the game.

      One area of particular concern is the window of opportunity for a player to block after their opponent has begun a punch. Currently that window is one-tenth of a second, otherwise you will be to late to counter their blow. I want it to be difficult to successfully pull off a block and have it be something that requires real attention to accomplish. I'm wondering though if it isn't too difficult right now, which may encourage mindless button mashing, which is certainly not what I want to condone.

      Another consideration is whether having three main actions (block, attack, charge) provides a good balance. My idea with having three main areas is that your two thumbs will have to leave one section uncovered at all times. This should result in hand movements that telegraph actions to the opponent.

      Aside from these, any other constructive criticism is very welcome.

      My game can be found at the Google Play Store here:

      NOTE There is a known graphics error when performing a special punch. There are no doubt other unknown errors as well.

        Thank you for your time, I hope you'll be able to find some fun in this little game!

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!