There's two things going on here!
fixing the first should fix the second.
First is that you say it turns into bug type 2 before returning home, now if we look at the code we see that move_towards_point(Obj_Ant_Home.x, Obj_Ant_Home.y, 3);
is actually within the scope of if BugType = 1 {
.
So when the bug gets to the food, they become BugType 2, and then your code to return home never actually runs.
so 2nd thing:
The reason your ant keeps on moving is likely because move_towards_point()
actually changes the object's built-in speed
variable, which is probably never being set back to 0. SO, once BugType
becomes 2, the return home code doesn't run, and the bug continues along at the speed they were last going.
all that to say you might want something like this:
if (instance_exists(Obj_Food_Small))
{
BugType = 1;
move_towards_point(Obj_Food_Small.x, Obj_Food_Small.y, 3)
}
else
{
BugType = 2;
move_towards_point(Obj_Ant_Home.x, Obj_Ant_Home.y, 3);
}
but the important thing is not to have the return home code in an area that is only executed when the bug is in "go get food" mode