GameMaker: Studio

GameMaker: Studio

View Stats:
bugman96 14 Aug, 2014 @ 11:16am
If I set a path while touching the wall, game crashes?
Hi, I have had this problem for days with no luck. If I create a path while player_obj is touching wall_obj, the game will nearly always crash (Stop responding). However, creating paths while not touching the wall it has never crashed. Here's my code for the paths:

if(instance_exists(target_obj)) {
with (target_obj) instance_destroy();
path_clear_points(path);
path_delete(path);
}

if(place_free(mouse_x,mouse_y)){
target = instance_create(mouse_x, mouse_y, target_obj);
}

if (instance_exists(target_obj)){
path = path_add();
mp_potential_path_object(path, target_obj.x, target_obj.y, 1, 100, wall_obj);
path_start(path, 5, 0, 0);

}

:(
< >
Showing 1-2 of 2 comments
Daynar 14 Aug, 2014 @ 7:08pm 
I suspect a memory leak. Are all these blocks of code in the same event? If they arnt I suspect the first block doesnt get called when you are colliding with a wall. This would likely cause you to create paths without first deleting the existing path. Then you have a whole bunch of paths just chillin around taking up your oh so sweet memory.
I'd suggest using
if path_exists(path) path_delete(path) //path creation code
to test to see if this is the case.
That said I've never used paths before so I may be completely wrong.
I also thing you could condence those 3 code blocks into just the 2nd one and not even create target objects or whatever, but I could be wrong.
DIdnt thought about this way. You helped me with this. lmao
< >
Showing 1-2 of 2 comments
Per page: 1530 50