Mathf.Lerp happens instantly

Hello,

I have this script that it’s supposed to move the player 1 unit to the right smothly when I press Space. The problem is that he gets moved instantly, like teleporting. What’s wrong?

//clickPos is the position the time we click to move the player
var clickPos : int = don.transform.position.x;
don.transform.position.x = Mathf.Lerp(clickPos, clickPos + 1, 0.5);

Lerp is just a very simple math function that returns a value instantly, like most any other function. If you want to use Lerp to do stuff smoothly, you need to call it repeatedly (in a coroutine typically, or Update) while advancing the third parameter from 0.0 to 1.0.

that is not how Mathf.Lerp is supposed to work. The rightmost parameter tells the function how much add to clickpos but it is not cumulative, it is meant always starting from the base value, clickpos in the specific. So your instruction is actually telling to go, each time is called, from clickpos to clickpos+0.5, therefore going instantly halfway the x position you would reach.
To achieve what you need you have to change that 0.5 with, i.e., something that will increment by the time, like:
(Time.time - startTime) * speed
where startTime initialized with Time.time before your instruction starts looping, and speed a value used to control the Lerp speed to complete the gap between the starting value and the value to reach.