GML How to find the nearest no collision point?


For example I have a big object and a small object. When the small object collides with the big object, small object needs to find the nearest position where it's not colliding with the big object.

I need this because if the player get stucked in the wall, he need to unstuck but not simply moving at random direction. Instead of this, he needs to move at direction that is nearest to him.
Not sure exactly what you are looking for here. Possibly you what the big object to push the small object around? If so...
//collision event//
var power=1
x-= lengthdir_x(power,point_direction(x,y,other.x,other.y))
y-= lengthdir_y(power,point_direction(x,y,other.x,other.y))


If you're trying to move out of the collision and then move to the point before the collision:

[Collision event with obj_big]

// Backtrack to previous position
x = xprevious;
y = yprevious;

// Move forward until you're next to the big instance
var dx = lengthdir_x(1, direction);
var dy = lengthdir_y(1, direction);
while (!place_meeting(x + dx, y + dy, obj_big))
x += dx;
y += dy;