Rotation isn't working right.

I cannot rotate a object towards another i have tried:
transform.LookAt (target.transform.position); this makes the object move extremely slow and sometimes moves backwards.
transform.Rotate(target.transform.position); which just spins it like crazy and if i set x and z to 0 it just spins around
and
transform.rotation = Quaternion.Slerp(transform.rotation,Quaternion.Euler(0, target.transform.position.y, 0),Time.deltaTime * 5); and yet again doesn’t work
can you please help me with this problem.

Here is my code.

void Move(){
        transform.Translate ((Vector3.forward * (1 * size) / 2) * Time.deltaTime);

        if (freemove == true) {
            counter++;
            if (counter >= 100) {
                direction = Random.Range (-1, 2);
                counter = 0;
            }
            if (direction == 0)
                transform.Rotate (Vector3.up);
            if (direction == -1)
                transform.Rotate (Vector3.down);
        } else if (freemove == false) {
            //transform.LookAt (target.transform.position);
            transform.Rotate(target.transform.position);
            //transform.rotation = Quaternion.Slerp(transform.rotation,Quaternion.Euler(0, target.transform.position.y, 0),Time.deltaTime * 5);
            Debug.Log(target.transform.position);
        }
    }

You’re trying to rotate the object by a coordinate, which will not work. You’re thinking of how to do this completely wrong.

Let’s say you have Object A, and Object B. You’re rotating Object A on the X-axis by Object B’s Y position. You’re thinking it will make Object A look at Object B’s height, but, in reality, you will just add the Y position of Object B to Object A’s X-axis. So, if Object B is 1 unit up from the ground, then the X axis rotation will increase by 1 every time you rotate the object, which will cause it to spin.

As for transform.LookAt, that should not make your object more slowly/backwards. Try using transform.LookAt(traget.transform) instead, that may work better.

If you’re confused on how to use it, read up on the documentation here.

I figured out why its moving slowly or backwards, because it follows an enemy that’s smaller then it, It tries to go down slightly which is causing it do drag slower. How do i make LookAt(); only apply to turning not looking down or up.

Just use the x and z (or y - depending on your use of axis) values of your target and the y value of the current gameobject itself. Like

new Vector3(targetobject.transform.position.x, this.transform.position.y, targetobject.transform.position.z)

This obv. only works if your terrain is flat, though.