2023-03-24 04:22:51 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using SHADE;
|
|
|
|
|
|
|
|
|
|
namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework
|
|
|
|
|
{
|
2023-03-24 07:41:05 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-03-24 04:22:51 +08:00
|
|
|
|
public class NavigationTestScript :Script
|
|
|
|
|
{
|
|
|
|
|
public GameObject endPoint;
|
|
|
|
|
|
|
|
|
|
public float speed = 1.0f;
|
2023-03-24 07:41:05 +08:00
|
|
|
|
float timer = 0.0f;
|
2023-03-24 04:22:51 +08:00
|
|
|
|
|
|
|
|
|
protected override void start()
|
|
|
|
|
{
|
2023-03-24 07:41:05 +08:00
|
|
|
|
|
|
|
|
|
Navigation nav = GetComponent<Navigation>();
|
|
|
|
|
Transform endTransform = endPoint.GetComponent<Transform>();
|
|
|
|
|
if (endTransform)
|
|
|
|
|
nav.MoveTo(endTransform.GlobalPosition);
|
2023-03-24 04:22:51 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void update()
|
|
|
|
|
{
|
2023-03-24 07:41:05 +08:00
|
|
|
|
timer += Time.DeltaTimeF;
|
2023-03-24 04:22:51 +08:00
|
|
|
|
Navigation nav = GetComponent<Navigation>();
|
|
|
|
|
Transform transform = GetComponent<Transform>();
|
2023-03-24 07:41:05 +08:00
|
|
|
|
if (timer >= 1.0f)
|
2023-03-24 04:22:51 +08:00
|
|
|
|
{
|
2023-03-24 07:41:05 +08:00
|
|
|
|
timer = 0.0f;
|
|
|
|
|
|
2023-03-24 04:22:51 +08:00
|
|
|
|
Transform endTransform = endPoint.GetComponent<Transform>();
|
2023-03-24 07:41:05 +08:00
|
|
|
|
if (endTransform)
|
2023-03-24 04:22:51 +08:00
|
|
|
|
nav.MoveTo(endTransform.GlobalPosition);
|
2023-03-24 07:41:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (nav && transform)
|
|
|
|
|
{
|
2023-03-24 04:22:51 +08:00
|
|
|
|
transform.LocalPosition = transform.LocalPosition + ( nav.GetForward() * Time.DeltaTimeF * speed);
|
2023-03-24 13:26:18 +08:00
|
|
|
|
|
2023-03-24 04:22:51 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|