best way to move a 2D character in unity code example
Example: how to move a 2d character in unity
if (moveInput != 0)
{
velocity.x = Mathf.MoveTowards(velocity.x, speed * moveInput, walkAcceleration * Time.deltaTime);
}
else
{
velocity.x = Mathf.MoveTowards(velocity.x, 0, groundDeceleration * Time.deltaTime);
}