Reader small image

You're reading from  Unity Virtual Reality Projects

Product typeBook
Published inSep 2015
Reading LevelIntermediate
PublisherPackt
ISBN-139781783988556
Edition1st Edition
Languages
Right arrow
Author (1)
Jonathan Linowes
Jonathan Linowes
author image
Jonathan Linowes

Jonathan Linowes is a VR/AR enthusiast, Unity, and full stack developer, entrepreneur, certified Unity instructor, and the owner of Parkerhill XR Studio, an immersive media, applications, and game developer. Jonathan has a bachelor of fine arts degree from Syracuse University, a master of science degree from the MIT Media Lab, and has held technical leadership positions at Autodesk and other companies. He has authored multiple books on VR and AR published by Packt Publishing.
Read more about Jonathan Linowes

Right arrow

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:

  1. Create an empty game object and name it GameController.

  2. Attach a new C# script to it, using Add Component, named KillTarget.

  3. 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 = 0;
    countDown...
lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Unity Virtual Reality Projects
Published in: Sep 2015Publisher: PacktISBN-13: 9781783988556

Author (1)

author image
Jonathan Linowes

Jonathan Linowes is a VR/AR enthusiast, Unity, and full stack developer, entrepreneur, certified Unity instructor, and the owner of Parkerhill XR Studio, an immersive media, applications, and game developer. Jonathan has a bachelor of fine arts degree from Syracuse University, a master of science degree from the MIT Media Lab, and has held technical leadership positions at Autodesk and other companies. He has authored multiple books on VR and AR published by Packt Publishing.
Read more about Jonathan Linowes