Advertisement
Ch0nG

Laser

Aug 21st, 2014
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.54 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class Laser : MonoBehaviour {
  5.  
  6.     private Transform TS;
  7.     public int wspeed = 8;
  8.  
  9.     void Start() {
  10.         TS = transform;
  11.     }
  12.  
  13.     // Update is called once per frame
  14.     void Update () {
  15.                 TS.Translate (Vector3.up * wspeed * Time.deltaTime);
  16.  
  17.                 if (TS.position.y > 7.5) {
  18.                         Destroy (this.gameObject);
  19.                 }
  20.         }
  21.  
  22.         void OnTriggerEnter(Collider collider)
  23.         {
  24.             if (collider.CompareTag("Enemy")) {
  25.             Destroy(this.gameObject);
  26.             Player.score += 50;
  27.             print(Player.score);
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement