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.
41 lines
909 B
41 lines
909 B
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class SetActiveAction :ActionNode
|
|
{
|
|
|
|
public GameObject go;
|
|
|
|
private bool actionIsOver = true;
|
|
private Vector3 targetPos;
|
|
|
|
public override IEnumerator Execute()
|
|
{
|
|
if (actionIsOver)
|
|
{
|
|
|
|
targetPos = new Vector3(-5, 0.5f, -1.3f) + new Vector3((Random.insideUnitCircle * 4f).x, 0, (Random.insideUnitCircle * 4f).y);
|
|
|
|
}
|
|
|
|
Vector3 dir = (targetPos - go.transform.position).normalized;
|
|
go.transform.position += dir * 0.25f;
|
|
if (Vector3.Distance(go.transform.position, targetPos) > 1f)
|
|
{
|
|
Debug.Log("行进中");
|
|
actionIsOver = false;
|
|
}
|
|
else
|
|
{
|
|
Debug.Log("行进完成,下一点");
|
|
actionIsOver = true;
|
|
}
|
|
|
|
return base.Execute();
|
|
|
|
}
|
|
|
|
|
|
}
|