private void UpdateWeapon() { if (Input.GetButton("Fire1")) { holder.Fire(); } if (Input.GetKeyDown(KeyCode.Alpha0)) { holder.ChangeWeapon(-1); } for (int i = 0; i < 9; i++) { if (Input.GetKey(KeyCode.Alpha1 + i)) { holder.ChangeWeapon(i); } } }
private void Start() { // get the components on the object we need ( should not be null due to require component so no need to check ) agent = GetComponentInChildren <UnityEngine.AI.NavMeshAgent>(); character = GetComponent <ThirdPersonCharacter>(); holder = GetComponent <WeaponHolder>(); agent.updateRotation = true; agent.updatePosition = false; agent.stoppingDistance = shootRange; holder.ChangeWeapon(0); if (!target) { var targetGO = GameObject.FindGameObjectWithTag("Player"); if (targetGO) { target = targetGO.transform; } } }