Exemplo n.º 1
0
    private void Update()
    {
        if (!EventSystem.current.IsPointerOverGameObject())
        {
            if (Input.GetMouseButtonDown(0) && !isRespawning)
            {
                //Gets the Mouse Position
                Vector2 mouseScreenPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
                mouseGO.transform.position = mouseScreenPosition;
                // get direction you want to point at
                Vector2 direction = (mouseScreenPosition - (Vector2)transform.position).normalized;
                // set vector of transform directly
                transform.up = direction;
                shooterScript.ShootChild(shotPrefab, gameObject.transform);
                //Instantiate(shotPrefab,shotSpawnLocation.transform.position,Quaternion.identity);
                myRigidBody.AddForce(-lookDir.up * forceToAdd);
                GetComponent <AudioSource>().PlayOneShot(shootAudio[Random.Range(0, shootAudio.Length)]);
            }
        }

        PlayerHealthSpriteChanger(health);
    }