void MoveToward()
{
if (path == null)
{
currNode = target.transform.position;
}
else
{
currNode = path[nodeIndex];
}
if (DebugMode)
{
for (int i = 0; i < path.Count - 1; ++i)
{
Debug.DrawLine((Vector3)path[i], (Vector3)path[i + 1], Color.magenta, 0.01f);
}
}
if (canMove)
{
Vector3 newPos = transform.position;
if ((currNode - newPos).magnitude < 0.25) //Reached target
{
if (m_target == currNode)
{
//ChangeState(State.IDLE);
MoveOrder(target.transform.position, toP);
}
else
{
nodeIndex++;
onNode = true;
if (path != null && nodeIndex < path.Count)
currNode = path[nodeIndex];
else
{
MoveOrder(target.transform.position, toP);
}
}
}
/***Move toward waypoint***/
//Debug.Log(currNode);
//newPos += motion;
Debug.DrawLine(transform.position, currNode, Color.red, 0.01f);
Vector3 motion = new Vector3(currNode.x, 0, currNode.z);
targPos = motion;
//newPos += motion * m_speed;
//transform.position = newPos;
}
}