public override void OnFrame(Entity entity) { pathfindingState.SetNewTarget(targetWaypoint.GetState <PositionState>().Position); if (Vector3.Distance(entity.GetState <PositionState>().Position, pathfindingState.GetTargetPosition().GetValueOrDefault()) < pathfindingState.GetStoppingDistance() + PositionTolerance) { pathfindingState = entity.GetState <PathfindingState>(); pathfindingState.ClearTarget(); ActionStatus = ActionStatus.Succeeded; } //TODO: Add timeout => Failure. }
public override void OnStart(Entity entity) { pathfindingState = entity.GetState <PathfindingState>(); targetWaypoint = entity.GetState <ActionBlackboardState>().TargetEntity; if (targetWaypoint != null) { pathfindingState.SetNewTarget(targetWaypoint.GetState <PositionState>().Position); pathfindingState.SetStoppingDistance(StoppingDistance); } else { Debug.LogWarning("GotToMovingWaypointAction failed as there was no waypoint. This shouldn't happen"); ActionStatus = ActionStatus.Failed; } }
public override void OnStart(Entity entity) { pathfindingState = entity.GetState <PathfindingState>(); var targetWaypoint = entity.GetState <ActionBlackboardState>().TargetEntity; if (targetWaypoint != null) { targetPosition = targetWaypoint.GetState <PositionState>().Position; targetRotation = targetWaypoint.GetState <RotationState>().Rotation.eulerAngles.y; pathfindingState.SetNewTarget(targetPosition, targetRotation); pathfindingState.SetStoppingDistance(0f); } else { Debug.LogError("GotToWaypointAction failed as there was no waypoint. This shouldn't happen!"); ActionStatus = ActionStatus.Failed; } }
public override void OnStart(Entity entity) { pathfindingState = entity.GetState <PathfindingState>(); pathfindingState.SetNewTarget(targetPosition); pathfindingState.SetStoppingDistance(stoppingDistance); }