private IEnumerator Attack() { while (true) { anim.SetBool("Walking", false); agent.Stop(); anim.SetTrigger("Attack"); yield return(new WaitForSeconds(4f)); } }
public override void Reason(Transform player, GameObject self) { if (selfHealthScript.currentHealth <= 0) { agent.Stop(); parentFSM.SetTransition(FSMTransitions.OutOfHealth); } else if (Vector2.Distance(self.transform.position, player.position) > agroRange) { agent.Stop(); parentFSM.SetTransition(FSMTransitions.PlayerOutOfRange); } }
public override void Reason(Transform player, GameObject self) { if (curHealthScript.currentHealth <= 0) { agent.Stop(); parentFSM.SetTransition(FSMTransitions.OutOfHealth); } else if (Vector2.Distance(self.transform.position, player.position) >= retreatEndDistance) { agent.slowingDistance = normalSlowingDistance; agent.Stop(); parentFSM.SetTransition(FSMTransitions.CloserDistanceReached); } }
/// <summary> /// Called to sacrifice Ally AI to heal player. /// </summary> public void AssimilateIntoPlayer() { #region Consts for readability const string _assimilatedAlly = "Assimilator"; #endregion Consts for readability #region Variable Instantiation _isAIActive = false; PolyNavAgent agent = gameObject.GetComponent <PolyNavAgent>(); #endregion Variable Instantiation agent.Stop(); gameObject.tag = _assimilatedAlly; gameObject.GetComponent <CircleCollider2D>().enabled = false; GameObject newLight = Instantiate(assimilationIndicator, transform); newLight.transform.localPosition = new Vector3(0, 0, -0.7f); // emit particles for a bit before dying; ParticleSystem regenSparkles = Instantiate(assimilationParticles, transform); regenSparkles.transform.localScale = new Vector3(0.02f, 0.06f, 0.06f); _myCombatController.Die(false, 2.5f); }
public void Work(float worktime, System.Action finish_cb) { if (is_working_) { return; } agent_.Stop(); is_working_ = true; rest_worktime = worktime; work_finish_cb_ = finish_cb; }
public void StopMove() { if (moveCoroutine != null) { StopCoroutine(moveCoroutine); moveCoroutine = null; _PlayerState = PlayerState.Idle; if (navAgent != null) { navAgent.Stop(); } } }
static int Stop(IntPtr L) { try { ToLua.CheckArgsCount(L, 1); PolyNavAgent obj = (PolyNavAgent)ToLua.CheckObject <PolyNavAgent>(L, 1); obj.Stop(); return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
void ExitState() { if (onExitState != null) { onExitState(); } ResetControllerVeriables(); StopAllCoroutines(); if (agent != null) { agent.Stop(); } }
/// Update is called once per frame void Update() { // Remove all player control when we're in dialogue if (FindObjectOfType <DialogueRunner>().IsDialogueRunning == true) { agent.Stop(); return; } if (Input.GetMouseButtonDown(1)) { destination = Camera.main.ScreenToWorldPoint(Input.mousePosition); agent.SetDestination(destination); } // Detect if we want to start a conversation if (Input.GetMouseButtonDown(0) && eventPanel.activeInHierarchy == false) { CheckForNearbyNPC(); } }
protected void Follow(PolyNavAgent agent, float distanceFollow, bool front) { if (followCrono < 2f) { agent.Stop(); anim.SetBool("Walking", false); followCrono += Time.deltaTime; } else { followCrono = 2f; anim.SetBool("Walking", true); if (front) { if (player.GetComponent <Character_Behaviour>().isLookLeft) { agent.SetDestination(new Vector2(player.transform.position.x - (distanceFollow * 0.8f), player.transform.position.y)); } else { agent.SetDestination(new Vector2(player.transform.position.x + (distanceFollow * 0.8f), player.transform.position.y)); } } else { if (player.GetComponent <Character_Behaviour>().isLookLeft) { agent.SetDestination(new Vector2(player.transform.position.x + (distanceFollow * 0.8f), player.transform.position.y)); } else { agent.SetDestination(new Vector2(player.transform.position.x - (distanceFollow * 0.8f), player.transform.position.y)); } } } }
protected override void EndSkill() { m_polyNavAgent.Stop(); isOrigMoveDisabled = false; SetSkillState(SkillState.none); }
protected void doLogic() { if (!isPointsCollected) { BuildPatrolPoints(); } AssessTarget(); if (Target != null) { if (!Target.activeInHierarchy) { State = PrimaryEnums.AiState.Wander; } if (Vector2.Distance(transform.position, Target.transform.position) <= minAttackDistance) { State = PrimaryEnums.AiState.Attack; } else if (State == PrimaryEnums.AiState.Attack && Vector2.Distance(transform.position, Target.transform.position) >= maxAttackDistance) { State = PrimaryEnums.AiState.Follow; } else if (State != PrimaryEnums.AiState.Attack && Vector2.Distance(transform.position, Target.transform.position) > minAttackDistance) { State = PrimaryEnums.AiState.Follow; } } else { State = PrimaryEnums.AiState.Wander; } switch (State) { case PrimaryEnums.AiState.Wander: Speed = (int)(MaxSpeed * 0.5f); agent.maxSpeed = Speed; TargetPos = PatrolPoints[currentPatrolPoint].position; CheckPath(TargetPos); break; case PrimaryEnums.AiState.Follow: Speed = (int)MaxSpeed; agent.maxSpeed = Speed; TargetPos = Target.transform.TransformPoint(TargetTrackingOffset); CheckPath(TargetPos); break; case PrimaryEnums.AiState.Attack: if (!isStationaryAttacker) { Speed = (int)MaxSpeed; agent.maxSpeed = Speed; if (Target == null) { return; } TargetPos = Target.transform.TransformPoint(TargetTrackingOffset); CheckPath(TargetPos); } else { agent.Stop(); } if (!isAttacking) { Attack(); isAttacking = true; } break; default: break; } }
protected override void Stop() { polyNavAgent.Stop(); }
/// <summary> /// nulls out an objects current nav path. /// </summary> public void StopNavigation() { _myNavAgent.Stop(); }