/// <summary> /// Attacks the target when in range. /// </summary> private IEnumerator Attack() { while (true) { if (agentState == AgentState.Attacking) { if (target == null) { break; } shooting = true; agent.destination = transform.position; transform.LookAt(target.transform); gun.Shoot(); if (Vector3.Distance(transform.position, target.position) > targetAttackDistance) { agentState = AgentState.Tracking; } } else { shooting = false; } yield return(new WaitForSeconds(targetAttackInterval)); } }
private void OnTriggerPress(SteamVR_Action_Boolean fromAction, SteamVR_Input_Sources fromSource) { if (behaviour != null) { if (behaviour.Shoot()) { if (source != null) { source.Stop(); source.clip = clipShoot; source.Play(); } if (gunAnimator != null) { gunAnimator.SetTrigger("Shoot"); } } else { if (source != null) { source.Stop(); source.clip = clipEmpty; source.Play(); } } } else { Debug.LogWarning(this + " Component is missing GunBehaviour script!"); } }
// Update is called once per frame void Update() { Move(); gun.Shoot(ammo, projectilePos); SwitchWeapon(); SwitchAmmo(); }
public void Shoot(Vector2 Target) { if (DEBUG) { Debug.Log("I am trying to shoot at: " + Target); } //Shoot The Gun if (Gun) { Gun.Shoot(); } }
void Update() { if (info.IsAutomatic) { if (Input.GetButton("Fire1")) { RaycastHit hit; bool hitSuccess; (hitSuccess, hit) = controller.Shoot(); if (hitSuccess) { if (hit.transform.CompareTag("Target")) { TargetBehaviour target = hit.transform.GetComponent <TargetBehaviour>(); target.TakeDamage(Convert.ToSingle(info.Damage)); } } } } }