敌人AI攻击方法的编写
老师 | Trigger
学习者 |小白
出品 | Siki 学院
```java
public class Enemy : MonoBehaviour
{
//属性值
public float movespeed = 3;
private Vector3 bullectEulerAngles;
private float v = -1;
private float h;
//引用
private SpriteRenderer sr;
public Sprite[] tanksprite;// 上 右 下 左
public GameObject bullectPrafabs;
public GameObject explosionPrefab;
//计时器
private float timeVal;
private float timeValChangeDirection;//改变方向的计时器
private void Awake()
{
sr = GetComponent();
}
void Update()
{
//攻击的时间间隔
if (timeVal >= 3f)
{
Attack();
}
else
{
timeVal += Time