public void SetLandMode() { curMode = userMode = DroneMode.Land; targetBehavior = targetDirectBehavior; target = transform.position; target.y = droneScr.HeightOfGround(); effectiveTarget = targetBehavior.GetEffectiveTarget(transform, target, thisScript); EnterLandingState(); }
public void SetHoverMode() { curMode = userMode = DroneMode.Hover; targetBehavior = targetDirectBehavior; target = transform.position; target.y = hoverHeight; effectiveTarget = targetBehavior.GetEffectiveTarget(transform, target, thisScript); EnterAdjustHeightState(); }
private void EnterAtDestinationState() { LeaveState(); curState = FSMDroneState.AtDestination; if (debugFSM) { Debug.Log(string.Format("{0}: Entering", curState)); } // If the user has changed the travel or motion mode, make the switch here. SetUserTravelAndMotion(); if (curMode == DroneMode.Maintain) { // In Maintain mode, do not do anything. return; } if (curMode == DroneMode.Hover) { effectiveTarget = targetBehavior.GetEffectiveTarget(transform, target, thisScript); EnterAdjustHeightState(); } if (curMode == DroneMode.Patrol || curMode == DroneMode.Follow) { if (!nextWaypoint) { Debug.LogError("Error: nextWaypoint must be set in the Inspector."); SetMaintainMode(); return; } } if (curMode == DroneMode.Patrol) { // If patrolling and waypoint reached, identify the next waypoint. targetBehavior.AdvanceWaypoints(nextWaypoint, target, thisScript); EnterAdjustLateralState(); } if (curMode == DroneMode.Follow) { // If following, constrained to waypoints, and waypoint has been reached, // identify the next waypoint. if (CloseToNextWaypoint()) { targetBehavior.AdvanceWaypoints(nextWaypoint, target, thisScript); effectiveTarget = targetBehavior.GetEffectiveTarget(transform, target, thisScript); } if (CloseToPrevWaypoint()) { targetBehavior.AdvanceWaypoints(prevWaypoint, target, thisScript); effectiveTarget = targetBehavior.GetEffectiveTarget(transform, target, thisScript); } if (!AtTargetLateralPos()) { EnterAdjustLateralState(); } } }
public void SetPatrolMode() { if (!nextWaypoint) { Debug.LogError("Error: nextWaypoint must be set in the Inspector."); SetMaintainMode(); } else { curMode = userMode = DroneMode.Patrol; targetBehavior = targetWaypointBehavior; targetBehavior.DroneTargetInit(thisScript); // Find the closest waypoint. This may be any of the waypoints if the drone has been controlled manually. DroneWaypointScript wpScript = nextWaypoint.GetComponent <DroneWaypointScript>(); nextWaypoint = wpScript.NearestWaypoint(transform.position); //prevWaypoint = null; target = nextWaypoint.transform.position; effectiveTarget = targetBehavior.GetEffectiveTarget(transform, target, thisScript); EnterAdjustHeightState(); } }
public void SetPatrolMode() { if (!nextWaypoint) { Debug.LogError("Error: nextWaypoint must be set in the Inspector."); SetMaintainMode(); } else { curMode = userMode = DroneMode.Patrol; targetBehavior = targetWaypointBehavior; targetBehavior.DroneTargetInit(thisScript); // Find the closest waypoint. This may be any of the waypoints if the drone has been controlled manually. DroneWaypointScript wpScript = nextWaypoint.GetComponent<DroneWaypointScript>(); nextWaypoint = wpScript.NearestWaypoint(transform.position); //prevWaypoint = null; target = nextWaypoint.transform.position; effectiveTarget = targetBehavior.GetEffectiveTarget(transform, target, thisScript); EnterAdjustHeightState(); } }