using System.Collections; using System.Collections.Generic; using UnityEngine; public class Enemy : MonoBehaviour { [SerializeField] private float speed = 4.0f; // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { transform.Translate(Vector3.down * speed * Time.deltaTime); if(transform.position.y < -5f) { float randomX = Random.Range(-8f, 8f); transform.position = new Vector3(randomX, 7, 0); } } }