Attack and Damage

Enemies should attack the player, and the player should attack the enemies. Both depend on the concept of attacking and taking damage. In this section, we'll use particle systems for inflicting damage, and we'll create script to take damage. First, let's create a player weapon by generating a new particle system. In VR, this object can be made a child of the hand controllers; each hand can have one weapon. In standard first-person mode, the particle system will be a single-fire weapon. To get started for the player attack, create a new particle system in the scene by choosing GameObject | Effects | Particle System. See Figure 10.12:

Figure 10.12: Creating a weapon particle system

Once added, we'll need to tweak a lot of settings ...

Get Unity 2018 By Example - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.