Turret Targetting the opposite direction.

I’ve searched the forums and found many people having this problem and I’ve tried their solutions and I’ve even change the rotation of the model so it aligns properly to unity xyz but no matter what I do the turret changes to the opposite direction from the actual cube and the cube is the enemy. If I move the cube the turret targets the wrong way and moves as it should but just on the wrong way. I am new to scripting on unity… well I am new to much of unity so I have reached a point where my research over google has come empty. Any help would be appreciated. (I’ve also tried adding the turret to an empty object and made that turn 90deg. The turret still turns the wrong way) The project is on a 2d mode.

using UnityEngine;
using System.Collections;

public class TurretFire : MonoBehaviour {

	public GameObject shot;
	public Transform shotSpawn1;
	public Transform shotSpawn2;
	public float fireRate;

	private float nextFire;

		private GameObject target;

	void Start(){
		target = GameObject.FindWithTag ("Enemy");

	void Update () {

		//Automated Fire - TURRET
		if(Time.time > nextFire){
			nextFire = Time.time + fireRate;
			Instantiate (shot, shotSpawn1.position, shotSpawn1.rotation);
			Instantiate (shot, shotSpawn2.position, shotSpawn2.rotation);


		transform.LookAt (transform.position + new Vector3 (0, 1, 0), target.transform.position - transform.position);


For a 3D model with the front size facing positive ‘z’, you can just do:


But typically for 2D, the model is a sprite with the front side facing right when the rotation is (0,0,0). Then you can do:

 Vector3 dir = target.position - transform.position;
 float angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg;
 transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward);

Note that your use of:

target.transform.position - transform.position

…for the second parameter of the LookAt() is strange since you are setting the axis of rotation to be along the same vector that the LookAt() should be using.