2D rotation problem

How can I make enemy rotate and go towards the target position automatically instead of using


I tried

 Enemy2.rotation = Quaternion.Lerp(Enemy2.rotation, Quaternion.LookRotation
(target.position - Enemy2.position), rotationSpeed*Time.deltaTime);

Which worked almost perfect when I had my target and enemy Transforms.
The only problem with that was that when rotating it was also spinning.


var target : Transform; //the enemy's target
var moveSpeed = 6; //move speed
var rotationSpeed = 0; //speed of turning

var MinSpeed : float;
var MaxSpeed : float;
var currentSpeed : float;

var Enemy2 : Transform; //current transform data of this enemy

function Start()

     target = GameObject.FindWithTag("Player").transform; //target the player

function Update () {

            //rotate to look at the player
            Enemy2.rotation = Quaternion.Lerp(Enemy2.rotation,
            Quaternion.LookRotation(target.position - Enemy2.position), rotationSpeed*Time.deltaTime);
     //move towards the player
    Enemy2.position += Enemy2.forward * moveSpeed * Time.deltaTime * 1.5; // <-- Adjust Speed Going Down
     if (transform.position	.y <= 0) // <-- Adjust Speed Up Atack Distance
     	transform.Translate(Vector3.down * .08, Space.World);
     if (transform.position	.y <= -4.2)  // <-- Adjust When To Reset Position Back To Top
     currentSpeed = Random.Range(MinSpeed, MaxSpeed);
    		x = Random.Range(-6f, 6f);
    		y = 7.0f;
    		z = 0.0f;
     transform.position = new Vector3(x, y, z);

Rotation issues normally stem from a ‘badly orientated’ model, especially since your first attempt looked like the way to go.

An attempt you need to make:
 - create an empty gameobject
 - drop your model inside the new empty gameobject
 - make a prefab out of the empty gameobject which now contains your model
 - reassign the scripts from your original model to the newly created prefab

The issue is simple: if you needed to rotate your original model, its axes could have swapped, and the ‘look’ functions specifically and invariably use the FORWARD and TOP vectors of the transform, to perform their actions.

I tried but it didn’t work.
I think my problem is somewhere in using Quaternion.LookRotation instead of transform.rotation

I am trying to figure out how to use look at target possition or follow target with transform.rotation.

Right now it follows target great but when I go under it from left to right or vice versa it spins to to make rotation .

You can only see that if you use different shape than sphere or more than one color on sphere.

Spin also causes it got thru plane (background) and come back.
I just need more of turn effect since it is 2d where enemy is coming down from top.