コード例 #1
0
ファイル: PointAndShoot.cs プロジェクト: Kerem94/Outbreak
    // Update is called once per frame
    void Update()
    {
        // Handles the weapon rotation
        if (!IsPointerOverUIObject())
        {
            target = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, transform.position.z));
            crosshairs.transform.position = new Vector2(target.x, target.y);

            Vector3 difference = target - player.transform.position;
            float   rotationZ  = Mathf.Atan2(difference.y, difference.x) * Mathf.Rad2Deg;
            player.transform.rotation = Quaternion.Euler(0.0f, 0.0f, rotationZ);
            if (timeBtwShots <= 0)
            {
                if (Input.GetMouseButtonDown(0))
                {
                    float   distance  = difference.magnitude;
                    Vector2 direction = difference / distance;
                    direction.Normalize();
                    fireBullet(direction, rotationZ);
                    muzzel(direction, rotationZ);
                    timeBtwShots = startTimeBtwShots;
                    //laden = true;
                    a_animation.SetTrigger("isLaden");
                    cm.spieler_is_laden();
                    SoundManagerScript.PlaySound("shotgun_laden");
                }
            }
            else
            {
                timeBtwShots -= Time.deltaTime;
            }
            // Debug.Log("Not over gameobject");
        }
        else if (UnityEngine.EventSystems.EventSystem.current.IsPointerOverGameObject())
        {
            // Debug.Log("over gameobject");
        }
    }