Moving an object smoothly with a set distance and time

So, I have an object which I want to move with values given in the inspector, for example I want the object to travel 1 unit with a 3 second time. Here’s what I’m using:

This executes if isR1InUse is true (it keeps executing in the Update function of the base class) and only stops when the same variable is set to false as I do it in the code below when the time ends.

It does three seconds but the object travels way more than just one unit. What am I doing wrong?

    protected override void MeleeAttack()
{
    Vector3 startingPos = meleeWeapon.transform.localPosition;

    meleeWeapon.transform.localPosition 
        = Vector3.Lerp(startingPos, startingPos += new Vector3(0, 0, maxMeleeDistance), meleeAttackSpeed * Time.deltaTime);

    timeElapsed += Time.deltaTime;
    if (timeElapsed >= meleeAttackSpeed)
    {
        isR1InUse = false;
        timeElapsed = 0;
    }
}

to understand the basic math for this. first you need to know the distance you are traveling on the x and y from point a to b.

you can get this by simply subtracting the finish from the start.
this gives you a vector that represents distance and direction.

time.deltatime is a cute unity function that tells you how often your update is running in one second.
so multiplying your distance vector by time.deltatime is the same as dividing out the movement your object needs to move to accomplish its goal in once second… finally if you multiply by your amount of seconds you wish to reach your goal. you will be traveling at that rate.

i hope this helps

float seconds;	
    Vector3 begin;
    		Vector3 end;
    		Vector3 difference ;
    
    void Start () {		
    		 seconds = 5;
    
    		begin = transform.position;
    		end = new Vector3 (11, 12, 13);
    		difference = end - begin;
}
    
    		void Update(){
    		transform.position += difference * Time.deltatime* seconds;
    		}