O'Reilly logo

Building an FPS Game with Unity by John P. Doran

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Spawning enemies with the help of a trigger

Enemies are computationally expensive to have spawned throughout the entire game project. A little trick that we use as game developers is spawning enemies right before a player enters an area; this way, they don't need to be created until they're ready to be seen! We can to this through the use of a property called a trigger.

  1. Let's first open the level that we created in Chapter 3, Prototyping Levels with Prototype that we used earlier in this chapter. We will need to add in navigation data to make things easier to work with. Create an empty game object by navigating to GameObject | Create Empty and set Position as 0,0,0. Then, call the game Environment.
  2. Once we have the object created, drag and drop ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required