Buy now! https://ozart.itch.io/mister-dongs-collector
GML code for having objects approach and avoid your player – change less than/greater than to angled brackets as youtube doesn’t allow:
if(distance_to_object(obj_player) less than 42)
{
// image_angle = point_direction(x, y, obj_player.x, obj_player.y);
move_towards_point( obj_player.x, obj_player.y, -3 );
}
if collision_circle(x, y, 42, all, false, true)
{
// image_angle = point_direction(x, y, obj_player.x, obj_player.y);
move_towards_point( obj_player.x, obj_player.y, -3 );
}
else speed = 0;
COLLISION
// If there wasn’t a collision
// in the previous X position
var colliding = instance_place(xprevious, y, obj_collision_parent);
if (!(colliding greater than 0))
{
// Then move back to that
// point on the X axis
x = xprevious;
y = y;
}
else
{
// If there wasn’t a collision
// in the previous y position
var colliding = instance_place(x, yprevious, obj_collision_parent);
if (!(colliding greater than 0))
{
// Then move back to that
// point on the Y axis
x = x;
y = yprevious;
}
else
{
// Otherwise just move back
// on both X and Y axes
x = xprevious;
y = yprevious;
}
}