Advertisement
Evilgit

Powercell

Jun 16th, 2013
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.72 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class PowerCell : MonoBehaviour
  5. {
  6.    
  7.     public float rotationSpeed = 100.0f;
  8.    
  9.     // Use this for initialization
  10.     void Start ()
  11.     {
  12.    
  13.     }
  14.    
  15.     // Update is called once per frame
  16.     void Update ()
  17.     {
  18.         transform.Rotate(new Vector3(0, rotationSpeed * Time.deltaTime, 0)); //Sets the cell's rotation speed to rotationSpeed variable (in degrees per frame)
  19.     }
  20.    
  21.     void OnTriggerEnter(Collider col)
  22.     {
  23.         if(col.gameObject.tag == "Player")
  24.         {
  25.             col.gameObject.SendMessage("CellPickup"); //Calls the CellPickup() to allow the player to get the powercell
  26.             Destroy(gameObject); //Destroys the powercell object in the game after the player interacted with it
  27.         }
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement