Chase script makes my sprite thin and blurry

I’m using this script I found here to make enemies chase my player.

``````using UnityEngine;
using System.Collections;

//[RequireComponent(typeof(CharacterController))]

public class Chaser : MonoBehaviour {

public float speed = 20.0f;
public float minDist = 1f;
public Transform target;

// Use this for initialization
void Start ()
{
// if no target specified, assume the player
if (target == null) {

if (GameObject.FindWithTag ("Player")!=null)
{
target = GameObject.FindWithTag ("Player").GetComponent<Transform>();
}
}
}

// Update is called once per frame
void Update ()
{
if (target == null)
return;

// face the target
transform.LookAt(target);

//get the distance between the chaser and the target
float distance = Vector3.Distance(transform.position,target.position);

//so long as the chaser is farther away than the minimum distance, move towards it at rate speed.
if(distance > minDist)
transform.position += transform.forward * speed * Time.deltaTime;
}

// Set the target of the chaser
public void SetTarget(Transform newTarget)
{
target = newTarget;
}

}
``````

It works, but it makes my enemy sprite all thin and blurry. Why?

Is this project in 2D? You should take a look at the enemy’s transform while the game is running to see if any rotation has been applied to the X or Y axes. `transform.LookAt` will align the objects `forward` vector in the direction of the target. However, `forward` is typically in the Z direction, even for 2D objects. This will end up applying rotation on X and Y which will cause the sprite to rotate away from the camera.

You may want to try using Quaternion.LookRotation to ensure that direction of `forward` does not change and that rotation is applied only to the Z axis.

``````Vector3 direction = target.position - transform.position;
Quaternion rotation = Quaternion.LookRotation(new Vector3(0, 0, 1), direction);
transform.rotation = rotation;
``````

Note that LookRotation will create a rotation to align the objects “up” to point at the target direction, so you may need to change the base sprite to be rotated accordingly.

Thanks. I put your code in and it worked, except I had to change it to (0, 0, 0) because the sprites were created looking up.