If looks could kill
We got this far. We might as well try to kill Ethan (haha!). Here are the specifications for this new feature:
- Looking at Ethan hits him with our line-of-sight ray gun
- Sparks are emitted when the gun hits its target
- After 3 seconds of being hit, Ethan is killed
- When he's killed, Ethan explodes (we get a point) and then he respawns at a new location
The KillTarget script
This time, we'll attach the script to a new empty GameController
object by performing the following steps:
- Create an empty game object and name it
GameController
. - Attach a new C# script to it, using Add Component, named
KillTarget
. - Open the script in MonoDevelop.
Here's the completed KillTarget.cs
script:
using UnityEngine; using System.Collections; public class KillTarget : MonoBehaviour { public GameObject target; public ParticleSystem hitEffect; public GameObject killEffect; public float timeToSelect = 3.0f; public int score; private float countDown; void Start () { score ...