Scripting the zombies
In this chapter, we'll finish up the ShootingRange
project with scripts and interactivity. Keep in mind that the approach we're taking is just a guide; it's designed to be embellished with your own creativity with regards to the environment and interactions in the world. So, with that said, let's get back to the action.
Summoning zombies
In Chapter 6,Scripting Zombies for the Oculus Rift, we constructed the scene, which included the environment, the Zombie
prefab, and a state machine to control the animations. We can now create the scripts needed to spawn enemies at the ZombieSpawnPoint
GameObjects.
ZombieSpawner script
The ZombieSpawner
is a simple script that randomly instantiates a zombie at one of the three ZombieSpawnPoint
points every few seconds. Take the following steps to set it up:
- Create an empty GameObject named
SpawnController
and position it anywhere in the scene. I generally like to put controller scripts at0
,0
,0
, but since our player will be anchored to...