Greetings
I upgraded to 3.6 and I’m running into an interesting quirk. My units don’t move along the path anymore and the paths that get calculated only have 2 points in them.
`public void onPathComplete(Path p)
{
if(!p.error)
{
_path = p;
_currentWaypoint = 0;
Debug.Log(_path.vectorPath.Count);
Debug.Log(_path.vectorPath[0]);
Debug.Log(_path.vectorPath[1]);
}
}
void FixedUpdate()
{
if(_path == null || _targetToMoveTo.HasValue == false)
{
return;
}
if(_currentWaypoint >= _path.vectorPath.Count)//End of PATH
{
_targetToMoveTo = null;
return;
}
//Move
Vector3 clampedPathPosition = new Vector3(_path.vectorPath[_currentWaypoint].x,0,_path.vectorPath[_currentWaypoint].z);
Vector3 direction = (clampedPathPosition - transform.position).normalized;
direction = new Vector3(direction.x,0,direction.z).normalized;
Vector3 distance = direction*_speed*Time.fixedDeltaTime;
Quaternion finalRotation = Quaternion.LookRotation(_targetToMoveTo.Value - transform.position);
transform.rotation = Quaternion.Lerp(transform.rotation,finalRotation,_rotationSpeed*Time.deltaTime);
transform.position += distance;
Vector3 clampedGameObjectPostion = new Vector3(transform.position.x,0,transform.position.z);
if(Vector3.Distance(transform.position,clampedPathPosition) < 0.2f)
{
_currentWaypoint++;
}
}
//On a mouse click event I get a raycast hit.point and I pass the point here
public Vector3 targetToMoveTo
{
set
{
_targetToMoveTo = value;
Vector3 clampedPostion = new Vector3(transform.position.x,0,transform.position.z);
_seeker.StartPath(clampedPostion,_targetToMoveTo.Value);
}
get{return _targetToMoveTo.Value;}
}
`
My units used to move along a path but now every time I click (no matter how far along the map I click), I get a vector path with a count of 2. Any idea whats up?