public void SetLastWayPoint() { if (Target) { LastWayPoint = Target.GetComponentInParent <IWayPoint>() ?? LastWayPoint; //If not is a waypoint save the last one } }
/// <summary> /// Set the next Target /// </summary> public virtual void SetTarget(Transform target) { if (target == null) { return; //If there's no target Skip the code } this.target = target; targetPosition = target.position; //Update the Target Position isActionZone = target.GetComponent <ActionZone>(); //TisAnimal = target.GetComponent<Animal>(); (WHAT HAPPENS IF THE TARGET IS AN ANIMAL ???? )) isWayPoint = target.GetComponent <MWayPoint>(); NextWayPoint = target.GetComponent <IWayPoint>(); //Check if the Next Target has Next Waypoints StoppingDistance = NextWayPoint != null ? NextWayPoint.StoppingDistance : DefaultStopDistance; //Set the Next Stopping Distance CheckAirTarget(); Debuging(name + " is travelling to : " + target.name); if (!Agent.isOnNavMesh) { return; //No nothing if we are not on a Nav mesh or the Agent is disabled } Agent.enabled = true; Agent.SetDestination(targetPosition); //If there's a position to go to set it as destination Agent.isStopped = false; //Start the Agent again }
public void MoveToDestination(IWayPoint start_waypoint, IWayPoint target_waypoint, float speed) { StopAllCoroutines(); List <IWayPoint> waypoints = TileManager.Instance.FindPath((Tile)start_waypoint, (Tile)target_waypoint, null).Cast <IWayPoint>().ToList(); StartCoroutine(PatrolWaypoints(CreateWaypoints(waypoints, speed))); }
/// <summary> /// Set to next Target /// </summary> public virtual void SetTarget(Transform target) { if (!Agent.isOnNavMesh) { return; //No nothing if we are not on a Nav mesh or the Agent is disabled } if (target == null) { return; //If there's no target Skip the code } this.target = target; targetPosition = target.position; //Update the Target Position isActionZone = target.GetComponent <ActionZone>(); isWayPoint = target.GetComponent <MWayPoint>(); NextWayPoint = target.GetComponent <IWayPoint>(); //Check if the Next Target has Next Waypoints StoppingDistance = NextWayPoint != null ? NextWayPoint.StoppingDistance : DefaultStopDistance; if (debug) { Debug.Log("Target Updated: " + target.name); } Agent.SetDestination(targetPosition); //If there's a position to go to set it as destination Agent.isStopped = false; }
public void SetLastWayPoint(Transform target) { var newLastWay = target.gameObject.FindInterface <IWayPoint>(); if (newLastWay != null) { LastWayPoint = target?.gameObject.FindInterface <IWayPoint>(); //If not is a waypoint save the last one } }
void Start() { Animal.isPlayer.Value = false; //If is using a brain... disable that he is the main player StartNewState(currentState); AIMovement.AutoNextTarget = false; LastWayPoint = null; if (AIMovement.Target) { SetLastWayPoint(AIMovement.Target); } }
/// <summary>Set the next Destination Position without having a target</summary> public virtual void SetDestination(Vector3 PositionTarget) { IsWaiting = false; animal.Mode_Interrupt(); //In Case it was making any Mode; Stopped = false; StoppingDistance = DefaultStopDistance; //Reset the Stoppping Distance Debuging(name + ": is travelling to : " + PositionTarget); IsZone = null; IsWayPoint = null; NextWayPoint = null; if (I_WaitToNextTarget != null) { StopCoroutine(I_WaitToNextTarget); //if there's a coroutine active then stop it } TargetPosition = PositionTarget; //Update the Target Position ResumeAgent(); }
/// <summary>Set the next Target</summary> public virtual void SetTarget(Transform target) { IsWaiting = false; animal.Mode_Interrupt(); //In Case it was making any Mode; Stopped = false; this.target = target; // Debug.Log("targetPosition: " + targetPosition.ToString("F2")); if (target == null) { Stop(); } else { TargetPosition = target.position; //Update the Target Position IsZone = target.GetComponent <Zone>(); IsWayPoint = target.GetComponent <MWayPoint>(); NextWayPoint = target.GetComponent <IWayPoint>(); //Check if the Next Target has Next Waypoints StoppingDistance = DefaultStopDistance; //Reset the Stoppping Distance if (NextWayPoint != null) { StoppingDistance = NextWayPoint.StoppingDistance; NextTarget = NextWayPoint.NextTarget; } // StoppingDistance = NextWayPoint != null ? NextWayPoint.StoppingDistance : DefaultStopDistance; //Set the Next Stopping Distance CheckAirTarget(); Debuging(name + ": is travelling to : " + target.name); ResumeAgent(); } }
void Start() { Animal.isPlayer.Value = false; //If is using a brain... disable that he is the main player if (currentState) { Debuging($"<color=white> Setting First AI State <B>[{currentState.name}]</B> </color>"); StartNewState(currentState); } else { enabled = false; return; } AIMovement.AutoNextTarget = false; LastWayPoint = null; if (AIMovement.Target) { SetLastWayPoint(AIMovement.Target); } }
void LogPos(IWayPoint wp) { MDebug.Log(wp.GetPosition().ToString()); }
void Ended(IWayPoint point) { target.OnMovementEnd -= Ended; target.OnMoveToWayPoint -= LogPos; target.OnWayPointreached -= LogPos; }
public WaypointInfo(IWayPoint p, float t, AnimationCurve c) { Waypoint = p; TimeToWaypoint = t; MovementCurve = c; }
public void SetLastWayPoint(Transform target) { LastWayPoint = target.GetComponentInParent <IWayPoint>() ?? LastWayPoint; //If not is a waypoint save the last one }
IEnumerator TurnToWaypoint(IWayPoint wp) { // MDebug.Log("Turn to"); yield return(new WaitForRotation(m_rotated.transform, M_Math.RotateToYFlat(m_rotated.transform.position, wp.GetPosition()), 0.35f)); // MDebug.Log("Rotated"); }
void OnMoveEnd(IWayPoint wp) { OnDestinationReached.AttemptCall(wp as Tile); Owner.GetComponent <WaypointMover>().OnMovementEnd -= OnMoveEnd; StartCoroutine(DelayedCompletion(0.5f)); }
public void Deconstruct(out GameObject enemy, out IWayPoint wayPoint) { enemy = EnemyToSpawn; wayPoint = StartWayPoint; }
public WaveSpawnData(GameObject enemy, IWayPoint waypoint) { EnemyToSpawn = enemy; StartWayPoint = waypoint; }