void Update()
    {
        if (HUDController.paused)
        {
            return;
        }

        Vector3 dirToMouse = MouseHelpers.VecToMouse(Origin.position);

        Origin.rotation = MouseHelpers.ObjectToMouseRotation(Origin.position);


        if (Input.GetMouseButtonDown(0))
        {
            SpawnProjectileAtTarget(dirToMouse);
        }

        if (Input.GetKeyDown(weaponButton))
        {
            repairBulletSelected = !repairBulletSelected;

            if (repairBulletSelected)
            {
                ChangePillDirection(pillSpriteObject, 0);
            }
            else
            {
                ChangePillDirection(pillSpriteObject, 180);
            }
        }
    }
Exemple #2
0
    void Update()
    {
        Vector3 pivotVector;

        if (followMouse)
        {
            pivotVector = MouseHelpers.VecToMouse(transform.position);
        }
        else
        {
            pivotVector = TargetToLookAt.position - transform.position;
            pivotVector.Normalize();
        }

        float angle = Mathf.Atan2(pivotVector.y, pivotVector.x) * Mathf.Rad2Deg;

        transform.rotation = Quaternion.AngleAxis(angle - 90, Vector3.forward);
    }