SHADE_Y3/Assets/Scripts/Gameplay/AIBehaviour/AIRework/NavigationTestScript.cs

53 lines
1.3 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SHADE;
namespace SHADE_Scripting.Gameplay.AIBehaviour.AIRework
{
public class NavigationTestScript :Script
{
public GameObject endPoint;
public float speed = 1.0f;
float timer = 0.0f;
protected override void start()
{
Navigation nav = GetComponent<Navigation>();
Transform endTransform = endPoint.GetComponent<Transform>();
if (endTransform)
nav.MoveTo(endTransform.GlobalPosition);
}
protected override void update()
{
timer += Time.DeltaTimeF;
Navigation nav = GetComponent<Navigation>();
Transform transform = GetComponent<Transform>();
if (timer >= 1.0f)
{
timer = 0.0f;
Transform endTransform = endPoint.GetComponent<Transform>();
if (endTransform)
nav.MoveTo(endTransform.GlobalPosition);
}
if (nav && transform)
{
transform.LocalPosition = transform.LocalPosition + ( nav.GetForward() * Time.DeltaTimeF * speed);
}
}
}
}