Revert "Create AIPrototype.cs"

This reverts commit b0054d62c6.
This commit is contained in:
mushgunAX 2022-11-02 11:37:03 +08:00
parent 2466ef00f3
commit 4eb7879bf2
1 changed files with 0 additions and 53 deletions

View File

@ -1,53 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using SHADE;
public class AIPrototype : Script
{
//This object's relevant components
private Transform transform;
[SerializeField]
[Tooltip("The list of waypoints that the object will move around on")]
private Vector3[] waypoints;
[SerializeField]
[Tooltip("How fast the object moves about waypoints")]
private float moveSpeed;
//To cycle depending on the length of waypoints
private int currentTargetWaypointIndex;
public AIPrototype(GameObject gameObj) : base(gameObj) { }
protected override void awake()
{
transform = GetComponent<Transform>();
if (transform == null)
{
Debug.LogError("Transform is NULL!");
}
currentTargetWaypointIndex = 0;
}
protected override void update()
{
//Head towards the next target
transform.GlobalPosition += (waypoints[currentTargetWaypointIndex] - transform.GlobalPosition) * moveSpeed * (float)Time.DeltaTime;
//Cycle to next waypoint if near enough
if ((waypoints[currentTargetWaypointIndex] - transform.GlobalPosition).GetSqrMagnitude() < 1.0f)
{
++currentTargetWaypointIndex;
if (currentTargetWaypointIndex == waypoints.Length)
{
currentTargetWaypointIndex = 0; //Recycle
}
}
}
}