Advertisement
lemansky

Untitled

Apr 4th, 2021
796
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.53 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class Bullet : MonoBehaviour
  6. {
  7.  
  8.     public float bulletSpeed = 10.0f;
  9.    
  10.     void Update()
  11.     {
  12.         transform.Translate(Vector3.forward * bulletSpeed * Time.deltaTime);
  13.         Destroy(this.gameObject, 3.0f);
  14.     }
  15.  
  16.     private void OnTriggerEnter(Collider other)
  17.     {
  18.  
  19.        if(other.gameObject.tag != "Enemy" && other.gameObject.tag != "PickUp")
  20.        {
  21.             Destroy(this.gameObject);
  22.        }
  23.  
  24.     }
  25.  
  26.  
  27. }
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement