Enemy not standing upright

i have an enemy with a character controller attached to it and the following script attached to the enemy to have it walk / attack the player…

The problem im having is that when the model is in motion, the enemy starts to rotate off axis and it just looks so bad ,…here is a picture:

Here is the script im currently using:

//object to be followed
var detectObject: Transform;
//distance that will trigger following action
var distanceDetection: float;
var standing = false;
var attackSpeed = 4;
//var AttackEnemy : GameObject;
private var characterController : CharacterController;
characterController = GetComponent(CharacterController);
private var gravity = 100.0;

function Start()
{
		//animation.wrapMode = WrapMode.Loop;
		//animation.Play("idle");
}

function Update () 
{
	
	if (detectObject)
	{
		var dist = Vector3.Distance(detectObject.position, transform.position);
		
		//if distance is less than what is specified then do something
		if(dist<distanceDetection)
		{
			//print("attack");
			//animation.CrossFade("walk");
			attack();
			return;
		
		}
		else
		{
			//print("stop attack");
			//animation.CrossFade("idle");
			GetComponent(SmoothLookAt).enabled = false;
			//GetComponent(ConstantForce).enabled = false;
		}

	}

}

function attack()
{
   direction = transform.TransformDirection(Vector3.forward * attackSpeed);
   characterController.SimpleMove(direction);
GetComponent(SmoothLookAt).enabled = true;


}

any ideas please?

My guess would be that the SmoothLookAt component is the cause – do you get the same problem if you disable/remove that component? Assuming that’s the problem, you probably need to adjust the SmoothLookAt target so its y-position is at the same height as the enemy object – i.e. ensure that the look-at vector will remain parallel to the ground.

i think that might be the problem but i tried the same thing on a friends computer, and the enemy rotating and followed the player perfectly fine…however, how i can adjust the y position height through script?