void Shot() { float shotDistance = 10000; Ray ray = new Ray(Barrel.position, Barrel.forward); RaycastHit hit; if (Physics.Raycast(ray, out hit, shotDistance, enemymask)) { if (hit.collider.GetComponent <Enemy>()) { hit.collider.GetComponent <Enemy>().TakeDamage(damage); } } if (Physics.Raycast(ray, out hit, shotDistance, terrormask)) { enemy = hit.transform.gameObject.GetComponent <AImov>(); enemy.shotat(); //if (hit.collider.GetComponent<AICharacterControl>()) //{ // hit.collider.GetComponent<AICharacterControl>().shotat(); //} } StartCoroutine("RenderTrace", ray.direction * shotDistance); //Debug.DrawRay(ray.origin, ray.direction * shotDistance, Color.red, 1); GetComponent <AudioSource>().Play(); }
public IEnumerator fire(AImov _owner, int random) { yield return(new WaitForSeconds(random)); eman = GameObject.FindWithTag("Manager").GetComponent <EnemyManager>(); muzzle.gameObject.GetComponent <ShootEnemy>().attacking = true; yield return(new WaitForSeconds(2)); muzzle.gameObject.GetComponent <ShootEnemy>().attacking = false; _owner.stateMachine.ChangeState(State_Default.Instance); eman.ticketreturn(); }
public void Shoot(AImov _owner) { int random = Random.Range(0, 3); StartCoroutine(fire(_owner, random)); }