private void controllerUpdate() { if (!m_movingAgent.isEquiped()) { switch (selectedWeaponType) { case Weapon.WEAPONTYPE.primary: m_movingAgent.togglePrimaryWeapon(); break; case Weapon.WEAPONTYPE.secondary: m_movingAgent.togglepSecondaryWeapon(); break; } } else { if (!m_movingAgent.isEquipingWeapon()) { m_movingAgent.aimWeapon(); } else { m_movingAgent.stopAiming(); } } if (moveCounter > 0.2f) { moveDirection = Random.insideUnitSphere; moveDirection.y = 0; moveCounter = 0; } Vector3 targetPostion = enemy.transform.position; targetPostion.y = 1.5f; m_movingAgent.setTargetPoint(targetPostion); if (isInScreenLimit() && enableFire) { //if (shootingCounter > 1) //{ // targetPostion = player.transform.position; // targetPostion = new Vector3(targetPostion.x, 1.2f + targetPostion.y, targetPostion.z); // m_movingAgent.setTargetPoint(targetPostion); // m_movingAgent.weaponFireForAI(); // shootingCounter = -Random.value * 3; //} //shootingCounter += Time.deltaTime * 2; if (!triggerPulled) { if (shootingCounter > 0.5f) { m_movingAgent.pullTrigger(); triggerPulled = true; shootingCounter = 0; } } else { if (shootingCounter > 0.5f) { m_movingAgent.releaseTrigger(); triggerPulled = false; shootingCounter = 0; tempFloat = Random.value * 10 + 1; } } } shootingCounter += Time.deltaTime; moveCounter += Time.deltaTime; // m_movingAgent.moveCharacter(moveDirection.normalized); }