Touch position returns weird behaviours

So I am transformig the rotation of my gameObject to the touch position. I need it to look at touch position.
first I tried using LookAt:


but it resulted in very weird behaviours.

And than I tried to use eualerAngles to alter the rotation of Z axis spesifically.

transform.eulerAngles = new Vector3(transform.rotation.x, transform.rotation.y, normalizedPosition.z * 1000);

But this resulted in very weird behaviours too.

Now finally what I tried as a last effort was to use transform.rotate.

transform.Rotate(0, 0, normalizedPosition.z * 1000);

This resulted in weird behaviour too.

Here’s my final code that I am using:

        if (Input.touchCount > 0)
            Debug.Log("Touched meh");
            touch = Input.GetTouch(0);
            Vector3 touchPosition = camera.ScreenToWorldPoint(touch.position);
            Vector3 normalizedPosition = (touchPosition - transform.position).normalized;
            if (transform.rotation.z != normalizedPosition.z)
                transform.Rotate(0, 0, normalizedPosition.z * 1000);

And heres what I mean by weird behaviour.

Your units aren’t lining up to anything intelligible, so code will have pretty much random outcomes. Transform.Rotate takes units in degrees, but you are actually supplying meters with the z-component of a Vector3.

But, you had the right idea, though. Normalizing the offset is your first step, turning that into a relative polar angle is the second:

void Update()
    if (Input.touchCount > 0)
        // It's more intuitive to just get the object's appearance on screen.  Casting
        // a screen point into the world is a little murky as you aren't always sure
        // of where it will end up.
        Vector3 mouse = Input.GetTouch(0).position;
        Vector3 thisOnScreen = Camera.main.WorldToScreenPoint(this.transform.position);

        // Get the noramlized difference between our mouse and object's screen representation
        Vector3 relative = (mouse - thisOnScreen).normalized;

        // Get a degree representation around the origin for that difference
        float theta = Mathf.Atan2(relative.y, relative.x);
        float thetaDegrees = theta * Mathf.Rad2Deg;

        // This will change depending on your situation.  In my case, it was just an arrow
        // point right, but you might need to add a multiple of 90 here to correct your heading.
        this.transform.rotation = Quaternion.Euler(Vector3.forward * thetaDegrees);

giving you something like: