예제 #1
0
    private void OnCollisionEnter(Collision collision)
    {
        GameObject bulletDamage = collision.gameObject;
        sHealth    health       = bulletDamage.GetComponent <sHealth>();

        if (health != null)
        {
            if (health.currentHealth > 0)
            {
                health.DamageTaken(10);
                Destroy(gameObject);
            }
        }
    }
    public void FireWeapon()
    {
        //Centers line based on view of camera
        rayCam = Camera.main.ViewportToWorldPoint(new Vector3(0.5f, 0.5f, 0.0f));
        RaycastHit hit;

        //Checks ammo
        if (Shells.currentShells > 0)
        {
            //Checks raycast
            if (Physics.Raycast(rayCam, PlayerCamera.transform.forward, out hit))
            {
                Shells.ammoLost(2);
                updateAmmo();
                sHealth s_Health = hit.transform.GetComponent <sHealth>();

                if (s_Health != null)
                {
                    s_Health.DamageTaken(70);
                }
            }
        }
    }