Esempio n. 1
0
    void RayShoot()
    {
        RaycastHit hitInfo;
        Vector3    center = new Vector3(Screen.width / 2, Screen.height / 2, 0);
        Ray        ray    = camera.ScreenPointToRay(center);

        if (Physics.Raycast(ray, out hitInfo, distance))
        {
            if (hitInfo.collider.gameObject.CompareTag("Enemy"))
            {
                ObjectController enemyScript = hitInfo.collider.gameObject.GetComponent <ObjectController>();
                enemyScript.Damage(damage, hitInfo.normal * (float)damage * -1);
            }
        }
    }