// Update is called once per frame void Update() { GetRaycast(); if (Input.GetButtonDown("Fire1")) { aimingComponent.Fire(); } if (HitsCanTake < 0) { Dead(); } }
void Attack() { if (player != null) { if (Vector3.Distance(player.transform.position, transform.position) < 125.0f) { tankAim.Aim(player.transform.position); Vector3 aimDirection = (player.transform.position - tankAim.transform.position); if (Mathf.Abs(Vector3.Distance(GetComponentInChildren <BarrelPivot>().transform.forward, aimDirection.normalized)) < 0.1f) { tankAim.Fire(); } } else { tankAim.Aim(randomDirection); } } }