Need help! Enemy follows player with its head!

I have a huge problem. The enemy chases after the player headfirst. I have spent all morning (a full five hours) trying to fix this problem. I have tried to fix it with code, inspector properties, and even by reimporting the model from 3ds max. With the destruction of my ego, I have found no solution; therefore, I am hoping for a miracle that someone has had a similar problem and has found a solution.
Here’s my code just incase:

#pragma strict
var detectedCheck : EnemyVolumeOne;
var willAttackCheck : boolean;
var target : Transform;
var moveSpeed = 4;
var damping : float = 4;

function Update () {
	detectedCheck = GetComponentInChildren(EnemyVolumeOne);
	if(detectedCheck.detected == true){
//player looks at me with wrong angle, i have the follow script right, but i need the enemy to follow me correctly.
		/*var relativePos = target.position - transform.position;
		var rotation = Quaternion.LookRotation(relativePos);
		transform.rotation = rotation;*/
		//transform.eulerAngles = new Vector3(0,transform.eulerAngles.y,0);
		/*var rotation = Quaternion.LookRotation(target.transform.position - transform.position);
		rotation.x = 0;
		transform.rotation = Quaternion.Slerp(transform.rotation,rotation,Time.deltaTime * damping);*/
		//transform.Translate(Vector3.forward * moveSpeed * Time.deltaTime *1);
		//transform.Translate(Vector3.up * moveSpeed * Time.deltaTime *-1);
		//transform.position += transform.up * moveSpeed * Time.deltaTime *-1;
		print("he's gonna get you");

People on this list have this problem all the time. I’m surprised you were not able to fix it by rotating it in 3ds Max. When your mesh is in Unity with a rotation of (0,0,0), the side you want to be front needs to be looking towards positive ‘z’. Typically there are three fixes:

  1. Fix the rotation of the model in 3ds max.
  2. Use an empty game object with your model as a child. The LookAt() script goes on the empty game object. You then rotate the child, visible object so that it is facing positive ‘z’ when the empty parent object as a rotation of (0,0,0).
  3. Use an additional rotation to ‘fix’ things.

For an addition rotation you would do your look something like:

transform.rotation = Quaternion.Euler(-90,0,0) * Quaternion.LookRotation(target.position - transform.position);

I don’t know how your model is currently rotated, so the 'Quaternion.Euler() is just a placeholder. You would need to experiment with different values until your enemy is facing the correct direction.

After struggling all day I finally found a solution! Did some digging and found this!

It still works for me :wink:
In Max: “Select rotate pivot only” make your rotation so X= 90 and the rest is 0 0
Export with Y as up.


If you have a Biped: ad a root note that has 90 0 0 in rotation and then link the biped to the root so the root becomes parent (Root)

Bingo he stands.
Hope it helps…

Answer found here:

Again thanks for the help.