浏览代码

Setting the right initial value for the way point index + added comments/renaming for clarity

/main
Amel Negra 3 年前
当前提交
e3126f25
共有 1 个文件被更改,包括 6 次插入4 次删除
  1. 10
      UOP1_Project/Assets/Scripts/Characters/StateMachine/Actions/MovementActions/PathwayMovementAction.cs

10
UOP1_Project/Assets/Scripts/Characters/StateMachine/Actions/MovementActions/PathwayMovementAction.cs


{
_agent = agent;
_isActiveAgent = _agent != null && _agent.isActiveAndEnabled && _agent.isOnNavMesh;
_wayPointIndex = 0;
_wayPointIndex = _wayPointIndex - 1; //Initialized to this value so we keep the right order from the waypoints list using the modulo method below
_roamingSpeed = config.Speed;
_wayppoints = config.Waypoints;
}

private Vector3 GetNextDestination()
{
Vector3 result = _agent.transform.position;
Vector3 nextDestination = _agent.transform.position;
//We check the modulo so when we reach the end of the array we go back to the first element
result = _wayppoints[_wayPointIndex].waypoint;
nextDestination = _wayppoints[_wayPointIndex].waypoint;
return result;
//Debug.Log("the next destination" + nextDestination);
return nextDestination;
}
}
正在加载...
取消
保存