Advertisement
Guest User

PaddleHandler.cs

a guest
Dec 29th, 2013
3,309
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.95 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3. public class PaddleHandler : MonoBehaviour {
  4.     //this creates an empty ParticleSystem variable that we can attach to the correct particlesystem in the editor
  5.     public ParticleSystem collision;
  6.     // Use this for initialization
  7.     void Start () {
  8.     }
  9.     // Update is called once per frame
  10.     void Update () {
  11.         //this if statement moves the paddle down
  12.         if(transform.position.z >0 && Input.GetKey(KeyCode.UpArrow)){
  13.             float zup = transform.position.z - 16 * Time.deltaTime;
  14.             transform.position = new Vector3(transform.position.x, 0, zup);
  15.         }
  16.         //this if statement moves the paddle up
  17.         if(transform.position.z < 7 && Input.GetKey(KeyCode.DownArrow)){
  18.             float zdown = transform.position.z + 16 * Time.deltaTime;
  19.             transform.position = new Vector3(transform.position.x, 0, zdown);
  20.         }
  21.     }
  22.     //this plays the particle effect during a collision
  23.     void OnCollisionEnter(Collision other){
  24.         collision.Play();
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement