Hey just bought the pro version, so that I could try out the local avoidance (really need it in my current project). Anyway I set it up, but couldn’t for the life of me get it to work with my current script, I could not get the simple move to work at all, tried everything I could think of. Finally I just went to see how your minebot script moved with the character controller, I saw that it relied upon CalculateVelocity from the AIPath script, I tried it out, but it doesn’t move how I need my AI to move, I need them to stay exactly along the path because it’s a grid based game and the AI is supposed to move like the classic snake game, so it needs exact path movement, not smooth movement. Any help would be greatly appreciated, my current code is posted below, don’t know if that helps at all. Thanks.
`using UnityEngine;
using System.Collections;
using Pathfinding;
using System.Collections.Generic;
public class RatAI1: MonoBehaviour {
public Seeker seeker;
public Transform target = null;
public bool completedPath = false;
public float repathRate = 0;
public Path path;
public int currentWaypoint = 0;
public float speed = 0;
public float nextWaypointDistance = 0;
public Rigidbody rb = null;
public float wTime;
public Transform clone;
public int chainLength;
public Transform animator;
public float animSpeed;
public PickUpControl pScript;
public float groundHeight;
List<Transform> childList = new List<Transform>();
Vector3 nextTarget;
bool moving = false;
Vector3 lookAtTarget;
float delta;
Transform cClone;
int chainAmount;
Transform cRenderer;
Transform destroyObj;
float freezeTime;
int maxColor;
Color tpColor;
public bool noTarget = false;
bool cloning = false;
void Start () {
StartCoroutine("StartPhase");
}
IEnumerator StartPhase(){
while(noTarget){
yield return null;
}
groundHeight = transform.position.y;
seeker.StartPath(transform.position, target.position, OnPathComplete);
StartCoroutine ("Move");
StartCoroutine ("StartupRPath");
}
void OnPathComplete(Path p){
if(!p.error){
path = p;
currentWaypoint = 0;
}
}
IEnumerator StartupRPath(){
while(currentWaypoint < 2){
yield return null;
}
Debug.Log ("Started");
StartCoroutine ("RecalculatePath");
}
IEnumerator RecalculatePath(){
while(true){
if(!noTarget){
if(currentWaypoint > 2){
seeker.StartPath(transform.position, target.position, OnPathComplete);
yield return new WaitForSeconds(wTime);
}
}
yield return null;
}
}
IEnumerator Move() {
while(true){
if(path != null){
while(noTarget){
yield return null;
}
moving = true;
nextTarget = path.vectorPath[currentWaypoint];
nextTarget.y = groundHeight;
delta = speed * Time.deltaTime;
lookAtTarget.x = nextTarget.x;
lookAtTarget.y = groundHeight;
lookAtTarget.z = nextTarget.z;
transform.LookAt (lookAtTarget);
while(moving){
transform.position = Vector3.MoveTowards (transform.position, nextTarget, delta);
if(Vector3.Distance(transform.position, nextTarget) == nextWaypointDistance){
currentWaypoint++;
moving = false;
}
yield return null;
}
yield return new WaitForSeconds(wTime);
}
yield return null;
}
}
}`