using System.Collections; using System.Collections.Generic; using UnityEngine; using TMPro; public class Bullet_movement : MonoBehaviour { [SerializeField] private float verticalSpeed = 15.0f; [SerializeField] private float remainInAir = 1.0f; private float counter = 0f; public GameObject player; private PlayerMovement playerMovement; // Start is called before the first frame update void Start() { player = GameObject.FindWithTag("Starship"); playerMovement = player.GetComponent(); } // Update is called once per frame void Update() { Movement(); } private void Movement() { transform.Translate(Vector3.up * Time.deltaTime * verticalSpeed); counter += Time.deltaTime; if (counter >= remainInAir) { Destroy(gameObject); } } private void OnTriggerEnter2D(Collider2D other) { if (other.CompareTag("Enemy")) { playerMovement.score += 1f; Destroy(gameObject); } } }