Can anyone tell me whats wrong with my MoveTowardsEnemy part of my script?

I am making a simple script to where when the player attacks, he moves toward the enemy. Now I got it to where the player will face the enemy, and move to him. But when the player moves towards the enemy he shrinks? and the closer he gets the slow he moves… and he just repeatedly runs into the enemy’s feet… and if I try to move I fall through the floor.

Any Ideas on whats wrong here?

This is the script I am using,

using UnityEngine;
using System.Collections;


public class PlayerAttack : MonoBehaviour {
	
	
	//----------Variables Start----------
	
	public 		int 		moveSpeed;
	public 		int 		rotationSpeed;
	
	public 		Transform 	target;
	private 	Transform 	myTransform;
	

	public 		float 		smooth 			= 5.0F;
	public 		float 		smoothTime 		= 0.3F;    
	
	public 		bool 		iAmAttacking 	= false;
	public 		bool 		iAmTargeting 	= false;
	
	private 	Vector3 	velocity 		= Vector3.zero;
	
	//----------Variables End------------
	
	
	//A quick reference of our transform.
	void Awake()
	{
		myTransform = transform;
	}
	
	
	// Update is called once per frame
	void Update () 
	{
		//If we are targeting something, Draw a line between the player, and the target.
		if(iAmTargeting)
		{
			GameObject go = GameObject.FindGameObjectWithTag("Enemy");
			target = go.transform;
			
			Debug.DrawLine(target.transform.position, myTransform.position, Color.red);
		}
		
		//Since when we are targeting/Fighting, our ThirdPersonController is disabled.
		//If we use any Input, enable our ThirdPersonController.
		if(Input.anyKey)
		{
			GameObject player = GameObject.Find("Player");
			PlayerAttack playerAttack = player.GetComponent<PlayerAttack>();
			playerAttack.iAmTargeting = false;
			playerAttack.iAmAttacking = false;
			
			ThirdPersonController thirdPersonController = player.GetComponent<ThirdPersonController>();
			thirdPersonController.enabled = true;
		}
		
		//If we are atttacking, the played will constantly face the enemy, and move towards them.
		if(iAmAttacking) 
		{
			transform.LookAt(target.transform);
			transform.position = Vector3.Lerp(transform.position, target.position, Time.deltaTime * smooth);
		}
	}
}

One, because you’re Lerping from points a > b, but your value is never 1; hence, your player will never arrive at his destination.

And two; it’s probably because you’re using LookAt…so your player is looking at the enemy’s actual location (the ground). You’re going to want to maintain your x/z rotation and only rotate about the y axis.

Once you get the horizontal rotation sorted, try experimenting with transform.Translate() to move your character instead of Lerping him around.