How to fix the rotation bug?

Hi,

I made this script and I don’t know why my enemy is rotating on hiself… I’m a beginner and the game that I am doing is a 2D RPG

The goal of the script is to do a line between the enemy and the player. Like that, the monster(slime) will follow this line to the player to attack him(eventually)…

public Transform target;

    public int moveSpeed;

    public int rotationSpeed;

    private Transform myTransform;
    ////////////////////////////////////////
    void Awake()
    {
        myTransform = transform;
    }



    void Start()
    {
        GameObject go = GameObject.FindGameObjectWithTag("Player");

        target = go.transform;
    }



    void Update()
    {
        Debug.DrawLine(target.transform.position, myTransform.position, Color.yellow);


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

        myTransform.position += myTransform.forward * moveSpeed * Time.deltaTime;
             
    }

Sorry for my english…

Thank you :slight_smile:

86511-capture.png