You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

27 lines
574 B

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);
}
}
}