Beispiel #1
0
 public void reload()
 {
     //reload noise
     WeaponSounds.PlaySound("reload");
     coroutine = waittoShoot(0.5f);
     StartCoroutine(coroutine);
 }
Beispiel #2
0
    public void Shoot()
    {
        shootable = false;
        WeaponSounds.PlaySound("snipershot");
        RaycastHit hitInfo; //info of raycast

        if (Physics.Raycast(ray, out hitInfo, range))
        {
            Debug.DrawLine(ray.origin, hitInfo.point, Color.red);
            Debug.Log(hitInfo.collider.name);                          // console log infor for development
            Health target = hitInfo.transform.GetComponent <Health>(); // finding health script on the hit target
            if (target != null)                                        //if there was a health script attached to the object
            {
                target.takeDamage(damage);                             //run take damage on ray cast hit object
            }
        }
        else
        {
            //couldnt find objects with weaponry
            Debug.DrawLine(ray.origin, ray.direction * range, Color.green);
            Debug.Log("false");
        }
        coroutine = waitandReload(0.5f);
        StartCoroutine(coroutine);
    }