I have created a script for an enemy AI but for some reason the values at the beginning are not in the editor (and the script itself has been behaving weirdly and not showing up sometimes).
Please help.
Script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Pathfinding;
public class EnemyAI : MonoBehaviour
{
public Transform target;
public float speed = 200f;
public float nextWaypointDistance = 3f;
Path path;
int currentWaypoint = 0;
bool reachedEndOfPath = false;
Seeker seeker;
Rigidbody2D rb;
// Start is called before the first frame update
void Start()
{
seeker = GetComponent<seeker>();
rb = GetComponent<RigidBody2D>();
seeker.StartPath(rb.position, target.position, OnPathComplete);
}
void OnPathComplete(Path p)
{
if(!p.error)
{
path = p;
currentWaypoint = 0;
}
}
// Update is called once per frame
void Update()
{
}
}
Screenshot of the script component in the editor: