Advertisement
johnnygoodguy2000

PipeMoveScript

Mar 17th, 2024
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.60 KB | Gaming | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class PipeMoveScript : MonoBehaviour
  6. {
  7.     public float moveSpeed = 5;
  8.     public float deadZone = -45;
  9.     // Start is called before the first frame update
  10.     void Start()
  11.     {
  12.        
  13.     }
  14.  
  15.     // Update is called once per frame
  16.     void Update()
  17.     {
  18.         transform.position = transform.position + (Vector3.left * moveSpeed) * Time.deltaTime;
  19.         if (transform.position.x < deadZone)
  20.         {
  21.             Debug.Log("Pipe Deleted");
  22.    
  23.             Destroy(gameObject);
  24.         }
  25.     }
  26. }
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement