Can't get joint to look at enemy

Hi,

I’ve been following this tutorial series here:
http://cgcookie.com/unity/lessons/2-sam-turret/

I have a Turret model that will use this code :

function Update () 
{
	if (myTarget)
	{
		
		aim_Pan.LookAt(myTarget);
		aim_Pan.eulerAngles = Vector3(0, aim_Pan.eulerAngles.y, 0);
		aim_Tilt.LookAt(myTarget);
		
		
		
		pivot_Pan.rotation = Quaternion.Lerp(pivot_Pan.rotation, aim_Pan.rotation, Time.deltaTime * turnSpeed);
		pivot_Tilt.rotation = Quaternion.Lerp(pivot_Tilt.rotation, aim_Tilt.rotation, Time.deltaTime * turnSpeed);
		
		
		if(Time.time >= nextFireTime)
		{
			FireProjectile();
		}
	}
}

and make my model look at the enemy, it works for the most part but the problem is its 90 Degrees off target. So it will look at the target but be off, it still follows it around but its always 90 degrees off target.

I’ve also tried this code to try and fix

function Update () 
{
	if (myTarget)
	{
		CalculateAimPosition(myTarget.position);
		
		aim_Pan.rotation = Quaternion.Lerp(aim_Pan.rotation, desiredRotation, Time.deltaTime * turnSpeed);
		
		aim_Tilt.LookAt(myTarget);
		
		
		
		pivot_Pan.rotation = Quaternion.Lerp(pivot_Pan.rotation, aim_Pan.rotation, Time.deltaTime * turnSpeed);
		pivot_Tilt.rotation = Quaternion.Lerp(pivot_Tilt.rotation, aim_Tilt.rotation, Time.deltaTime * turnSpeed);
		
		
		if(Time.time >= nextFireTime)
		{
			FireProjectile();
		}
	}
}

//Calculates what we need to do to aim at the target
function CalculateAimPosition (targetPos : Vector3)
{
	//Temp var, so we know where we are aiming, add aiming error to it
	var aimPoint = Vector3(targetPos.x, targetPos.y, targetPos.z);
	
	//set our desired rotation to the aimpoint, aim where we want to aim
	desiredRotation = Quaternion.LookRotation(aimPoint - aim_Pan.position);
}

But it still has the same problem.

I’ve also tried editing the model file. I’ve rotated the model in Maya but still the problem persists.

Any idea’s?

Your problem does not lie in the rotation of the model.
Rotation is imported, so it doesn’t made a difference.

Your problem is the rotation of the mesh. Unity has x as sideways, y as up and z as inwards. I’m guessing maya is similar to Blender with z being up, y being sideways and x being inwards (or something similar)

To fix it, either parent the mesh to a object, in unity, compensating for the rotation,
or
Rotate the mesh in Maya so that it fit’s the coordinate system Unity uses.

Hope this helps,
Benproductions1