void OnTriggerEnter(Collider col) { // Debug.Log(transform.name + " miner triggerEnter"); // Debug.Log(transform.name + ": dest: " + destinationName + "/ " + col.name); // Debug.Log(transform.name + " col: " + col.name + " colParentP: " + col.transform.parent.parent.name + "***************"); if (col.name == destinationName) { // Debug.Log(transform.name + ": miner reached destination: " + destinationName + "/ " + col.name); reachedDestination = true; navAgent.Stop(); miningTimerOn = true; if (isAssignedToAMine) { if (destinationName == castle.name) { KeepMiningAssignedMine(); //Changes the destination back to the mine } else { MinerReturnToCastle(); //Changes destination back to castle } } if (col.transform.parent.parent.name == "Hills") { // Debug.Log(transform.name + " ran into a hillLLLLLLLLLLLLLLLLLLL^^^^^^^^^^^^^^^^^^^^"); lastHillVisited = col.transform; if (col.name == destinationName) { //Stop and wait while "mining" navAgent.Stop(); miningTimerOn = true; CheckSurroundingsForMine(col.transform); } } else { // Debug.Log(transform.name + "NOT HILLSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS"); } } }
void Update() { if (follow == true) { if (agent.hasPath) { agent.Resume(); } else { agent.SetDestination(Player.transform.position); } } if (!monster.coolDown && !monster.stun) { if (Vector3.Distance(transform.position, Player.transform.position) <= monster.lookDist) { if (agent.velocity == Vector3.zero) { transform.LookAt(Player.transform.position); } //Se o jogador estiver ao alcance if (Vector3.Distance(transform.position, Player.transform.position) <= monster.Distance) { follow = true; } } else { follow = false; agent.Stop(); } } else { follow = false; agent.Stop(); } }
// Update is called once per frame void Update() { remainningDistance = agent.remainingDistance; if (Player.move && !Player.isDeath) { if (isAgentStopped) { agent.Resume(); isAgentStopped = false; } if (pauseDelay == 0) { if (!isRunningAway) { agent.destination = Pacman.transform.position; } if (isRunningAway && CompareVector(transform.position, returnPosition.position) && CompareVector(agent.destination, returnPosition.position)) { toNormalState(); } } else { --pauseDelay; if (pauseDelay == 0) { Time.timeScale = 1; agent.Resume(); agent.destination = returnPosition.position; } } } else if (Player.isDeath && !isAgentStopped) { agent.Stop(); isAgentStopped = true; } }
void Update() { if (started) { //get in position if (!in_position) { print("navigating"); agent.ResetPath(); agent.SetDestination(waypoint.position); if ((agent.transform.position - waypoint.position).magnitude < 1) { //reached target, begin bowing agent.Stop(); in_position = true; } } else { //start bowing if (bownum < numbows) { if (bowstarted) { if (Time.time - bowstart > bowtime) { //end bowing follower.anim.SetBool("bowing", false); bownum++; bowstarted = false; if (bownum == numbows) { agent.Resume(); follower.stay_put = false; //set global state follower.transform.Find("dialogue").GetComponent <Animator>().SetInteger("globalstate", 2); DialogueControl.globalstate = 2; } } } else { bowstart = Time.time; follower.anim.SetBool("bowing", true); bowstarted = true; } } } } }
/// <summary> /// Implements the destruction logic of the enemy. /// </summary> protected virtual void DestroyEnemy(bool destroyWithEffects) { //Disable targetPlayer = null; NavMeshAgent agent = GetComponent <NavMeshAgent>(); agent.Stop(); agent.updateRotation = false; agent.obstacleAvoidanceType = ObstacleAvoidanceType.NoObstacleAvoidance; GetComponent <Collider>().enabled = false; //Animation if (destroyWithEffects && anim != null) { anim.speed = 1f; anim.SetBool("Death", true); // Normal Scale Fade out. LeanTween.scale(gameObject, Vector3.zero, lifeTimeAfterDeath).setEase(LeanTweenType.easeOutQuart).setIgnoreTimeScale(true); } //if (!destroyWithEffects) //{ //if(enemyIdentifier == EnemyEnum.Coyote) { // AlternativeKillBurstPolyExplosion akbp = gameObject.AddComponent<AlternativeKillBurstPolyExplosion>(); //} //else //{ // SmallPolyExplosion smallPolyExplosion = gameObject.AddComponent<SmallPolyExplosion>(); //} //} //Event. OnEnemyDeath(); // Scale to zero to 'skip' the death animation if (!instantKilled) { transform.localScale = Vector3.zero; } // Destroy if (destroyWithEffects) { Destroy(gameObject, lifeTimeAfterDeath + 0.2f); } else { Destroy(gameObject); } }
void SetState(MonsterState state) { if (_state != state) { _state = state; switch (state) { case MonsterState.Patrol: _agent.Resume(); _targetPatrolPoint = Random.Range(0, PatrolPoints.Count); _animation.CrossFade(WalkAnimation); _agent.SetDestination(PatrolPoints[_targetPatrolPoint].position); break; case MonsterState.Chase: _agent.Resume(); _animation.CrossFade(WalkAnimation); break; case MonsterState.Attack: _lastAttackTime = -1f; if (_agent.isActiveAndEnabled) { _agent.Stop(); } _animation.CrossFade(AttackAnimation); break; case MonsterState.Idle: _timeTowait = Random.Range(MinIdleTime, MaxIdleTime); _timeWaiting = 0f; _animation.CrossFade(IdleAnimation); break; case MonsterState.Die: if (Random.Range(0f, 100f) < Info.DropChance) { var go = Instantiate(Resources.Load("PowerUpHeal") as GameObject); go.transform.position = new Vector3(transform.position.x, go.transform.position.y, transform.position.z); } UIRoot.SetActive(false); _agent.enabled = false; if (_collider != null) { _collider.enabled = false; } _animation.CrossFade(DieAnimation); _timeTowait = SpawnTime; break; } } }
void Update() { enemies = Physics.OverlapSphere(transform.position, target_finder_raduis, mask); if (enemies.Length > 0) { float dist = Vector3.Distance(transform.position, enemies[0].transform.position); current_traget = enemies[0].gameObject; if (dist <= near_enemy_distance) { attack = true; navMeshAgent.Stop(); } else { attack = false; navMeshAgent.Resume(); navMeshAgent.SetDestination(enemies[0].transform.position); } } else { attack = false; navMeshAgent.Resume(); navMeshAgent.SetDestination(enemyCastle.transform.position); current_traget = enemyCastle; } if (attack == false) { //path finding anim.Play("Run"); } else { if (Time.time > nextAttack) { anim.Play("ArrowAttack"); Rigidbody bullet_clone = Instantiate(arrow, fire_pos.position, fire_pos.rotation) as Rigidbody; bullet_clone.GetComponent <bullet>().parnet_target_tag = target_tag; bullet_clone.GetComponent <bullet>().damage_power = damage_power; bullet_clone.AddForce(fire_pos.forward * arrow_speed); transform.LookAt(current_traget.transform); // float rnd_dmg = Random.Range(damage_power / 1.2f, damage_power); // current_traget.SendMessage("ApplyDamage", damage_power); nextAttack = Time.time + atackRate; } } }
// Update is called once per frame void FixedUpdate() { distance = Vector3.Distance(Erica.transform.position, this.transform.position); // Debug.Log("distance = " + distance); if (distance <= 7.0f) { cou = StartCoroutine(Porowake()); } else if (distance > 7.0f) { anim.SetBool("EricaInAggroArea", false); nma.Stop(); } if (myStat.HP <= 0) { anim.SetBool("IsDead", true); Invoke("PoroDead", 1.0f); } }
public virtual void OnPause() { IsPaused = true; animator.speed = 0f; hitArea.enabled = false; audioSource.Pause(); if (navMeshAgent.isOnNavMesh) { navMeshAgent.velocity = Vector3.zero; navMeshAgent.Stop(); } }
private void Move() { if (Vector3.Distance(navMeshAgent.destination, transform.position) >= attackRange) { Debug.Log("Move range = " + attackRange); navMeshAgent.Resume(); walking = true; } else if (transform.position == navMeshAgent.destination) { navMeshAgent.Stop(); } }
public override TaskStatus OnUpdate() { if (m_agent.remainingDistance <= 1.0f) { m_agent.Stop(); return(TaskStatus.Success); } //if (m_tgp.PrintTest()) //{ // return TaskStatus.Success; //} return(TaskStatus.Running); }
// Update is called once per frame void Update() { if (!isAlive) { nav.Stop(); return; } if (GameManager.Instance.player != null) { nav.destination = GameManager.Instance.player.transform.position; } }
private void ChaseTarget() { if (Vector3.Distance(myTarget.transform.position, this.gameObject.transform.position) <= 4) { _navAgent.Stop(); DealDamage(myTarget); } else { _navAgent.Resume(); _navAgent.SetDestination(myTarget.transform.position); } }
public bool Damaged(int dmg) { mon_hpNow -= dmg; if (mon_hpNow <= 0) { NavMeshAgent agent = GetComponent <NavMeshAgent>(); agent.Stop(); died = true; GameObject.Find("ManaSystem").GetComponent <ManaSystem>().Dead_sign();//5.19일 홍승준 수정 return(true); } return(false); }
void OnTriggerEnter(Collider collider) { if (collider.CompareTag("Wall")) { GetComponent <ZombieMoving> ().MoveToPoint(GetComponent <ZombieMoving> ().moveFromPosition); } if (collider.CompareTag("Player")) { agent.Stop(); transform.parent.GetComponent <FollowTrigger> ().isAttacking = true; attackableTargets.Add(collider.gameObject); } }
public void haltMovement(bool halt) { if (halt) { powerhit = true; agent.Stop(); } else { powerhit = false; agent.Resume(); } }
public void OnDead() { agent.Stop(); Destroy(walkAgent); agent.enabled = false; mainPlague.amountPlague--; mainPlague.amountDead++; mainPlague.UpdateText(); //agent.isStopped = true; villager.GetComponent <Rigidbody>().AddForce(Vector3.forward * 50); villager.GetComponent <MeshRenderer>().material = Dead; PlagueTrigger.gameObject.SetActive(false); }
public override void Enter() { ProfessionRole expr_06 = SelfRole._inst; if (expr_06 != null) { NavMeshAgent expr_11 = expr_06.m_moveAgent; if (expr_11 != null) { expr_11.Stop(); } } }
void UpdateChase() { if (target == null) { state = State.Idle; animator.SetBool("TargetSpottedBool", false); } else { float distance = Vector3.Distance(transform.position, target.transform.position); if (distance <= attackRange) { state = State.Attack; animator.SetTrigger("AttackTrigger"); agent.Stop(); } else { agent.SetDestination(target.transform.position); } } }
/// <summary> /// Clears all the target properties /// </summary> public void ClearTarget() { if (_ClearTargetOnStop) { _Target = null; _TargetPosition = Vector3Ext.Null; mIsTargetSet = false; } mNavMeshAgent.Stop(); mHasArrived = false; }
// Update is called once per frame void Update() { if (Vector3.Distance(transform.position, player.position) < 1.4f) { agent.Stop(); anim.SetBool("Move", false); } else { agent.SetDestination(player.position); anim.SetBool("Move", true); } }
private IEnumerator getPath(Vector3 target) { lookTarget = target; var waitUpdate = new WaitForEndOfFrame(); myAgent.SetDestination(target); while (myAgent.pathPending) { yield return(waitUpdate); } myAgent.Stop(); path = myAgent.path; }
// Update is called once per frame void Update() { if (health <= 0) { curState = FSMState.Dead; nav.Stop(); } switch (curState) { case FSMState.Idle: UpdateIdleState(); break; case FSMState.Chase: UpdateChaseState(); break; case FSMState.Attack: UpdateAttackState(); break; case FSMState.Dead: UpdateDeadState(); break; } elapsedTime += Time.deltaTime; elapsedPathCheckTime += Time.deltaTime; }
// Update is called once per frame void Update() { //check to see if this entity is still living if (knockedback) { agent.Stop(); Debug.Log("Knocked Back: " + rigidbody.velocity.magnitude); if (rigidbody.velocity.magnitude >= 5.0f) { knockedback = false; rigidbody.velocity = Vector3.zero; } agent.Resume(); } //refresh the attack cooldown if (Time.time >= lastAttackTime + attackCooldown) { isAttacking = false; } ai.Update(transform); }
void OnTriggerEnter(Collider other) { // If the entering collider is the player... if (other.gameObject == player && skeletonHealth.currentHealth > 0) { // ... the player is in range. playerInRange = true; anim.SetTrigger("equipBow"); bow.SetActive(true); navMeshAgent.Stop(); skeletonRigidbody.constraints = RigidbodyConstraints.FreezePosition | RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationZ; } }
public void ChangeState() { if (active) { agent.Stop(); } else { agent.Resume(); } active = !active; }
/// <summary> /// Raises the trigger stay event. If the vehicle is in the stopTrigger while it is untriggered, have vehicle resume driving. /// </summary> /// <param name="other">Other.</param> void OnTriggerStay(Collider other) { NavMeshAgent nav = other.gameObject.GetComponent <NavMeshAgent>(); if (TriggersTriggered) { nav.Stop(); } else { nav.Resume(); } }
void Update() { bool withinRange = Vector3.Distance(player.position, transform.position) < dist; if (withinRange && enemyHealth.currentHealth > 0 && playerHealth.currentHealth > 0) { vac_nav.SetDestination(player.position); } else { vac_nav.Stop(); } }
public SplitGroup(GameUnit ownerUnit, GameUnit splitUnit, float angle, float splitFactor) { this.ownerUnit = ownerUnit; this.splitUnit = splitUnit; this.elapsedTime = 0f; this.origin = ownerUnit.gameObject.transform.position; this.splitFactor = splitFactor; SpawnRange range = this.ownerUnit.GetComponentInChildren <SpawnRange>(); this.rotationVector = Quaternion.Euler(0f, angle, 0f) * (Vector3.one * range.radius); this.rotationVector.y = 0f; NavMeshAgent agent = this.ownerUnit.GetComponent <NavMeshAgent>(); if (agent != null) { agent.ResetPath(); agent.Stop(); } agent = this.splitUnit.GetComponent <NavMeshAgent>(); if (agent != null) { agent.ResetPath(); agent.Stop(); } NetworkTransform transform = this.ownerUnit.GetComponent <NetworkTransform>(); if (transform != null) { transform.transformSyncMode = NetworkTransform.TransformSyncMode.SyncNone; } transform = this.splitUnit.GetComponent <NetworkTransform>(); if (transform != null) { transform.transformSyncMode = NetworkTransform.TransformSyncMode.SyncNone; } }
IEnumerator CheckMonsterAction() { while (true) { if (monsterstate == MonsterState.idle) { nvAgent.Stop(); animator.SetBool("isWalk", false); animator.SetBool("isSpawn", false); } else if (monsterstate == MonsterState.walk) { nvAgent.Resume(); nvAgent.speed = walkSpeed; nvAgent.destination = playerTr.position; animator.SetBool("isWalk", true); animator.SetBool("isRun", false); } else if (monsterstate == MonsterState.run) { nvAgent.Resume(); nvAgent.speed = runSpeed; nvAgent.destination = playerTr.position; animator.SetBool("isRun", true); animator.SetBool("isAttack", false); } else if (monsterstate == MonsterState.attack) { nvAgent.Stop(); animator.SetBool("isAttack", true); } else if (monsterstate == MonsterState.spawn) { nvAgent.Stop(); animator.SetTrigger("isSpawn"); } yield return(null); } }