using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Eagle : Enemy
{
public float speed;
public Transform up, down;
public bool isUp=true;
// Start is called before the first frame update
protected override void Start()
{
base.Start();
transform.DetachChildren();
}
// Update is called once per frame
void Update()
{
Move();
}
public void Move()
{
if(isUp)
{
rb.velocity = new Vector2(rb.velocity.x, speed * Time.deltaTime);
if(transform.position.y>=up.position.y)
{
isUp = false;
}
}
else
{
rb.velocity = new Vector2(rb.velocity.x, -speed * Time.deltaTime);
if(transform.position.y<=down.position.y)
{
isUp = true;
}
}
}
}