This following code does work, but I have one issue with it. Once the gameobject starts getting close to the player that it is chasing it slows down and does not continue going at a constant speed to the target. Is there another way I can code this to keep the speed constant even if the gameobject is close to the target?
This is the code I have but does not work as I hope.
Vector3 followXonly = new Vector3(target_position.x, transform.position.y, transform.position.z);
transform.position = Vector3.Lerp(transform.position, followXonly, enemy.speed * Time.deltaTime);