예제 #1
0
    private void Update()
    {
        Vector3 difference = Camera.main.ScreenToWorldPoint(Input.mousePosition) - transform.position;
        float   rotZ       = Mathf.Atan2(difference.y, difference.x) * Mathf.Rad2Deg;

        transform.rotation = Quaternion.Euler(0f, 0f, rotZ + offset);

        if (timeBtwShots <= 0)
        {
            if (Input.GetMouseButton(0))
            {
                shake.Camshake();
                Instantiate(projectile, shotPoint.position, transform.rotation);
                timeBtwShots = startTimeBtwShots;


                if (Input.GetMouseButtonUp(0))
                {
                    gunShot.enabled = false;
                }
            }
        }
        else
        {
            timeBtwShots -= Time.deltaTime;
        }
    }