protected void CheckTargetReach() { switch (legsState) { case LegsState.Idle: break; case LegsState.MovingToPosition: if ((targetPosition - myPosition.position).sqrMagnitude < dtrmSqTargetPositionReach) { legsState = LegsState.Idle; SendTargetReachMessage(); StopMovement(); } break; case LegsState.PursuingTarget: if ((targetActor.position - myPosition.position).sqrMagnitude < dtrmSqTargetPositionReach) { legsState = LegsState.Idle; SendTargetReachMessage(); StopMovement(); } break; case LegsState.FollowingTarget: Debug.LogWarning("Shouldn't be checking target reach in this state!"); break; default: Debug.LogError("Unknown state!"); break; } }
void Update() { if (legsState == LegsState.Idle) return; if ( ReachedTarget() ) { legsState = LegsState.Idle; return; } if (legsState == LegsState.MovingToPosition ) MoveTowards(targetPosition); else MoveTowards(targetTransform.position); }
public void Stop() { legsState = LegsState.Idle; }
public void Pursue(Transform actor) { legsState = LegsState.PursuingTransform; targetTransform = actor; }
public void Move(Vector3 position) { legsState = LegsState.MovingToPosition; targetPosition = position; }
public void Follow(Transform actor) { legsState = LegsState.FollowingTransform; targetTransform = actor; }
public void FollowTarget(DTRMPosition target) { legsState = LegsState.FollowingTarget; targetActor = target; }
public override void DTRMStart() { legsListeners = GetComponents(typeof(ILegsListener)); legsState = LegsState.Idle; }
protected void CheckTargetReach() { switch(legsState) { case LegsState.Idle: break; case LegsState.MovingToPosition: if ( (targetPosition - myPosition.position).sqrMagnitude < dtrmSqTargetPositionReach ) { legsState = LegsState.Idle; SendTargetReachMessage(); StopMovement(); } break; case LegsState.PursuingTarget: if ( ( targetActor.position - myPosition.position ).sqrMagnitude < dtrmSqTargetPositionReach ) { legsState = LegsState.Idle; SendTargetReachMessage(); StopMovement(); } break; case LegsState.FollowingTarget: Debug.LogWarning("Shouldn't be checking target reach in this state!"); break; default: Debug.LogError("Unknown state!"); break; } }
public void Stop() { legsState = LegsState.Idle; StopMovement(); }
public void PursueTarget(DTRMPosition target) { legsState = LegsState.PursuingTarget; targetActor = target; }