How to do smooth animations?

Smooth animations can be done using the lerp function.

Let’s say you want to animate the x/y position of an instance, but smoothly. For that, you’d first need “target” x/y values:

/// Create
targetX = x;
targetY = y;

You can set targetX and targetY to wherever you want the instance to move, and then have x and y follow the target values, using lerp():

/// Step
// Set target to mouse position
targetX = mouse_x;
targetY = mouse_y;

// Move x/y to targetX/Y by 10% (0.1)
var _t = 0.1;
x = lerp(x, targetX, _t);
y = lerp(y, targetY, _t);