Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


GML Code crash when pathing (memory problem?)


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 Bugman96   Members   -  Reputation: 111

Like
1Likes
Like

Posted 13 August 2014 - 01:55 PM

Hi, I am new to the forum. I decided to come here because I'm not getting and replies at the yoyogames forum. On my game on Gamemaker Pro, if you spam right click (which creates a path) the game will crash. Here's my code for the player object under "glob right press" event which creates the path etc:

if(instance_exists(target_obj)) {
    with (target_obj) instance_destroy();
    path_clear_points(path); //using this code and the one below, I thought it would solve memory problems arrrggg...
    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);
    
    }

Anyone, any ideas? I'm really stuck... and it would be sad to abandon it cause I worked for so long. sad.png



Sponsor:

#2 dejaime   Crossbones+   -  Reputation: 4053

Like
1Likes
Like

Posted 15 August 2014 - 09:22 PM

Did you try adding a minimum delay for the order? Like only allowing the pathfinder to work, say, 10 times per second for each entity (as in add a 100 ms cooldown to it)?

 

I really do not know anything about GameMaker, nor even what language it uses. In other words, this is a complete shot in the dark here.


Edited by dejaime, 16 August 2014 - 07:48 AM.


#3 jbadams   Senior Staff   -  Reputation: 19072

Like
1Likes
Like

Posted 15 August 2014 - 10:52 PM

Moving you to our APIs and Tools forum. smile.png

dejaime's idea sounds like a good one.  Basically, you want to check if the player has already created a path within x amount of time (I'd start with 500ms/half a second 200ms/5 times per second - test from there to see if you need a shorter or longer time for the game to feel responsive and to avoid the problem) and simply ignore the additional input if they already have -- this shouldn't make any difference to game play and should avoid a lot of unnecessary calculation if the player "spams" the right mouse button.

 

I do own a copy of Game Maker: Studio (it uses it's own language called GML for future reference dejaime) but haven't spent a lot of time experimenting with it, so I'm afraid I can't really offer a specific example either, but the basic idea should provide a good starting point.  Let us know if you can't figure it out and if no one else chimes in I'll fire up GM:S and see if I can put together an example for you.

 

 

Hope that helps! smile.png


Edited by jbadams, 16 August 2014 - 04:34 AM.
Adjusted suggested time interval to be more sensible -- posting when tired leads to silly thoughts!





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS