Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class PaddleHandler : MonoBehaviour {
- //this creates an empty ParticleSystem variable that we can attach to the correct particlesystem in the editor
- public ParticleSystem collision;
- // Use this for initialization
- void Start () {
- }
- // Update is called once per frame
- void Update () {
- //this if statement moves the paddle down
- if(transform.position.z >0 && Input.GetKey(KeyCode.UpArrow)){
- float zup = transform.position.z - 16 * Time.deltaTime;
- transform.position = new Vector3(transform.position.x, 0, zup);
- }
- //this if statement moves the paddle up
- if(transform.position.z < 7 && Input.GetKey(KeyCode.DownArrow)){
- float zdown = transform.position.z + 16 * Time.deltaTime;
- transform.position = new Vector3(transform.position.x, 0, zdown);
- }
- }
- //this plays the particle effect during a collision
- void OnCollisionEnter(Collision other){
- collision.Play();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement