Destroy gun when out of view

This commit is contained in:
2024-10-27 19:11:47 -07:00
parent 2908b53812
commit 0865da7870

View File

@@ -13,5 +13,9 @@ public class Gun : MonoBehaviour
void Update() {
transform.Rotate(new Vector3 (0, 0, Time.deltaTime * 1000));
if (Vector3.Distance(
transform.position,
GameObject.FindGameObjectWithTag("Player").transform.position
) > 20) Destroy(gameObject);
}
}