hi its me again, sorry for asking too many questions, but i have been looking for answers and stayed 1 hour trying to find the solution to this my self with no progress, i dont know how to make the ‘int’ a valid expression term
using System.CodeDom;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Threading;
using Pathfinding;
using UnityEngine;
public class enemy_AI : MonoBehaviour
{
public Transform target;
public float speed = 200f;
public float nextWaypointDistance = 3f;
public Transform enemyGFX;
Path Path;
float currentWaypoint = 0f;
bool reachedEndOfPath = false;
Seeker seeker;
Rigidbody2D rb;
void Start()
{
seeker = GetComponent<Seeker>();
rb = GetComponent<Rigidbody2D>();
InvokeReapeting("UpdatePath, 0f, .5f");
}
void UpdatePath()
{
if (seeker.IsDone())
seeker.StartPath(rb.position, target.position, OnPathComplete);
}
void OnPathComplete(Path p)
{
if (!p.error)
{
Path = p;
currentWaypoint = 0f;
}
}
void FixedUpdate()
{
if (Path == null)
return;
if (currentWaypoint >= Path.vectorPath.Count)
{
reachedEndOfPath = true;
return;
}
else
{
reachedEndOfPath = false;
}
Vector2 direction = ((Vector2)Path.vectorPath[currentWaypoint] - rb.position).normalized;
Vector2 force = direction * speed * Time.deltaTime;
rb.AddForce(force);
Cast(int); distance = Vector2.Distance(rb.position, Path.vectorPath[currentWaypoint]);
if (distance < nextWaypointDistance)
{
currentWaypoint++;
}
if (rb.velocity.x >= 0.01f)
{
enemyGFX.localScale = new Vector3(-1f, 1f, 1f);
}
else if (rb.velocity.x <= 0.01f)
{
enemyGFX.localScale = new Vector3(1f, 1f, 1f);
}
}
}