# My Enemy(Cube) Rotates in all axis... I just want it to rotate it in one axis

Can Someone Help me…Please explain me Quaternion.LookRotation and Quaternion.Slerp…My Enemy(Cube) Rotates in all axis I guess…I just want it to rotate it in one axis…How can i achieve that…

``````using UnityEngine;

using System.Collections;

public class Patrolling : MonoBehaviour {
public Transform[] patrolpoint;
public float speed;

private Quaternion _lookRotation;
private Vector3 _direction;
private int currentPoint;
// Use this for initialization
void Start ()
{
currentPoint = 0;
transform.position = patrolpoint [0].position;
}

// Update is called once per frame
void Update ()
{
if (transform.position == patrolpoint [currentPoint].position)
{
currentPoint++;
}

if (currentPoint >= patrolpoint.Length)
{
currentPoint=0;
}

_direction = (patrolpoint [currentPoint].position - transform.position).normalized;
transform.LookAt(patrolpoint[currentPoint]);
//create the rotation we need to be in to look at the target
_lookRotation = Quaternion.LookRotation(_direction);

//rotate us over time according to speed until we are in the required rotation
transform.rotation = Quaternion.Slerp(transform.rotation, _lookRotation, speed * Time.deltaTime);
transform.position = Vector3.MoveTowards (transform.position, patrolpoint [currentPoint].position, speed * Time.deltaTime);
}
}
``````

Instruct the cube to ignore the Y position of the target. e.g. Don’t tilt up or down.

``````_direction = (patrolpoint [currentPoint].position - transform.position).normalized;
_direction.y = 0f;

transform.LookAt(new Vector3(patrolpoint[currentPoint].position.x, transform.position.y, patrolpoint[currentPoint].position.z));
``````