Jump to content
  • Advertisement
  • entries
  • comments
  • views

Day 39 of 100 Days of VR: Creating a VR First Person Shooter II

Josh Chang


Welcome back to day 39!

Yesterday we started to look at fixing problems that involved the limitation of Mobile VR (and a lot of raycasting), today we’re going to make some more changes. Specifically, the goal today is:

  1. Change our Event Trigger logic to deal with what happens if we’re holding down on the screen
  2. Fix a problem with our player being pushed around
  3. Fix why our Knight turns black
  4. Change our enemy to be slower to make the game easier

Let’s get to it!

Step 1: Changing Our Event Trigger Logic for Continuous Fire

Right now, we’re trying to solve the problem where we only damage the enemies when we tap on them. If we were to hold on, then we would continue to shoot, but the enemies won’t take damage

Yesterday we discovered that there was 2 ways we could have implemented our game.

  1. Use our existing code where we shoot a raycast and depending on what we hit, run some function.
  2. Use the Event Trigger system along with Google’s changes.

I’ve played around quite a bit with the Event Trigger system and made a solution, but it’s not the best, in fact, I might have preferred just keeping what we have, but that’s okay, we’re just learning!

There are 2 problems that we must solve:

  1. What happens when we’re holding down the screen on an enemy
  2. What happens when we’re holding down and then we move to point at another enemy.

After playing around for a while, the PointerClick solution we have will no longer work.

Instead, I’ve started playing with the PointerEnter and PointerExit events.

I’m going to add the changes to EnemyHealth:

using System;
using UnityEngine;
using Random = UnityEngine.Random;

public class EnemyHealth : MonoBehaviour
    public float Health = 100;
    public AudioClip[] HitSfxClips;
    public float HitSoundDelay = 0.1f;

    private SpawnManager _spawnManager;
    private Animator _animator;
    private AudioSource _audioSource;
    private float _hitTime;
    private Boolean _isEnter;

    void Start()
        _spawnManager = GameObject.FindGameObjectWithTag("SpawnManager").GetComponent<SpawnManager>();
        _animator = GetComponent<Animator>();
        _hitTime = 0f;
        _isEnter = false;

    void Update()
        _hitTime += Time.deltaTime;
        if (Input.GetButton("Fire1") && _isEnter)
    private void TakeDamage(float damage)
        if (Health <= 0) { return; } if (_hitTime > HitSoundDelay)
            Health -= damage;
            _hitTime = 0;

        if (Health <= 0)

    private void SetupSound()
        _audioSource = gameObject.AddComponent<AudioSource>();
        _audioSource.volume = 0.2f;

    private void PlayRandomHit()
        int index = Random.Range(0, HitSfxClips.Length);
        _audioSource.clip = HitSfxClips[index];

    private void Death()
        foreach (Collider collider in GetComponentsInChildren<Collider>())
            collider.enabled = false;

    public void HealthEnter()
        _isEnter = true;

    public void HealthExit()
        _isEnter = false;

Walking Through the Code

In our EnemyHealth, we create 2 new functions:

  • HealthEnter()
  • HealthExit()

These functions are going to be called from the PointerEnter and PointerExit from our Event Trigger that we set up.

In these functions, we set new variable we introduced called _isEnter so we know when they’re being selected.

  1. Inside Update() we check to see if we’re currently hovering over the enemies and if we’re pressing down on the screen. If we are, we would call our already existing Shoot function.

I’m not a fan of this method because it requires us to constantly call Update() in all of our enemy health scripts as opposed to just inside our PlayerShootingController script, but for just playing around, this is okay.

  1. I also changed the hit sound effect to be able to play every 0.1 seconds just like our shooting delay.

Step 1.1: Updating our Event Trigger

Now that we have our shooting script in, the next and final thing we need to do is to create the Event Triggers to use them.

Get rid of the PointerClick event that we’ve previously set up. Instead, we’re going to create 2 new types of Event Triggers: PointerExit and PointerEnter.


Here’s what we’re going to do:

  1. Attach HealthEnter() to PointerEnter
  2. Attach HealthExit() to PointerExit

Now we can play our game like we intended to do from the very beginning. Make sure to make these changes to the Bandit and Zombie too!

Step 2: Preventing Our Player from Falling

Currently, if we were to play the game, when an enemy gets closed to our player character, we would fall.

We should have addressed this in the past when we set constraints inside our RigidBody component, but it appears that we have not.

Let’s go back and fix this

  1. In the hierarchy, select Player
  2. Under the RigidBody component, we’re going to set our constraints. Specifically, we want to freeze our position and rotation so that the enemies won’t push our character around. Having the game move us could cause nausea for our players.


Step 3: Fixing our Knight’s Color

If we were to play our game on our mobile device, we’ll notice one big problem. Our knights are all black.

If we pay attention to our log, we’ll see this:


It seems that we have some problems with the shaders that the asset is using.

Unfortunately, I don’t know enough about this problem to resolve this. We have 2 choices:

  1. Ignore the problem and just have all black knights
  2. Change the materials that use these to use the standard shader.

In our case, we’re going to explore the 2nd option.

  1. In Assets/Knight/models/Materials we have 3 materials that we’re using: clothColor, knight1Color, weaponsColor, and all of them uses one of those 2 shaders above. Let’s select them and changed them to Standard.


Now if we were to play the game on Unity, here’s what the knights would look like:


It lost the coloring we originally had for it, but at least we keep the details of the models.

Step 4: Making the Game Easier

Currently, in our game, we would be getting swarmed with enemies. That would have been fine if we can move around, unfortunately, we can’t do that anymore, thus as a result, we need to make some adjustments

We’re going to do 2 things:

  1. Change the rate of how long it takes for an enemy to spawn
  2. Slow down the rate our enemies move

Step 4.1: Changing Spawn Rate on the Spawn Manager

Currently, we spawn the next enemy every 2 seconds. Let’s change that to 5.

  1. Select the SpawnManager game object (child of GameManager)
  2. Set Time Between Enemies to be from 2 to 5


Step 4.2: Changing Enemy Walking Speed

As we might recall, to control the enemy speed, we must look at the Nav Mesh Agent component in our enemy prefabs.

In order of speed, our speed order is Bandit, Knight, Zombie, with the Bandit being the fastest and Zombie being the slowest.

I’m going to change the speed a bit.

  1. Bandit to 2
  2. Knight to 1.5
  3. Zombie to 1

Here’s an example:



Now we’re done! We have taken care of a lot of the technical problems that we encountered.

Tomorrow, we’re going to continue to finish the rest of the game by figuring out how we would add UI into a virtual reality environment.

Until then, I’ll see you all later in day 40!

Day 38 | 100 Days of VR | Day 40



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 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 kyle.cirkl@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!
    • By Vandallord
      Link: https://www.kongregate.com/games/Vandallord/idle-stone-history

      A wicked witch turned the main hero into the stone, you need to find a way to break the spell.
      Click on the objects and they will open.
      Click on the stone and its skill to attack the animals will grow as well as a the losses from clicking on animals.
      Click on the river to improve the function to manage time and clicks on the animals will be more precise.
      Click on the tree and it will give you things from animals and the level of luck will grow which give you an opportunity to Harder hits.
      The higher the level of monsters the more animal can visit the stone and give presents which are essential to make a portion.

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!