vdweller
Member
EDIT: Activation then Deactivation works if Activation happens, say, in the Step Event and Deactivation in the End Steap event. God help you if other parts of the code mess with this. This changes nothing. My butthurt is valid.
In the third episode of our Game Maker Studio 2 Bugathon, we have to deal with instance activation/deactivation.
In my game, in the master control object, every few steps some instances get activated/deactivated depending on their position in the view.
Now, in some specific places in the game, in another object, I am running some code where I want to temporarily activate some objects (to count them at any given time, for example), then deactivate them again.
I think you understand where this is going.
Instance activation/deactivation does not occur immediately. (This quirk existed in 1.4 too, but at least I found that things mostly worked if I placed that code in Begin Step event.)
We are talking about code like this:
Results (the number is the enemies present in the room (the correct number is 2)):
0 ,
++++++++++++++++++++++++++++ ,
2 ,
++++++++++++++++++++++++++++ ,
0 ,
++++++++++++++++++++++++++++ ,
0 ,
++++++++++++++++++++++++++++ ,
2 ,
++++++++++++++++++++++++++++ ,
0 ,
++++++++++++++++++++++++++++ ,
etc
No matter if I put the code in Begin, Normal or End Step, results are inconsistent. In an even more lulzy turn of events, functions like instance_number() don't work at all (always returns zero), hence the with statement in the beginning of the code. Executing this code every few steps instead of every step doesn't change anything, I tried that too in the ~10 hours I wasted trying to decipher this behavior.
My butthurt venting, after wasting so many hours, culminates into the following questionnaire:
In the third episode of our Game Maker Studio 2 Bugathon, we have to deal with instance activation/deactivation.
In my game, in the master control object, every few steps some instances get activated/deactivated depending on their position in the view.
Now, in some specific places in the game, in another object, I am running some code where I want to temporarily activate some objects (to count them at any given time, for example), then deactivate them again.
I think you understand where this is going.
Instance activation/deactivation does not occur immediately. (This quirk existed in 1.4 too, but at least I found that things mostly worked if I placed that code in Begin Step event.)
We are talking about code like this:
Code:
instance_activate_object(obj_enemy);
var z=0; with obj_enemy z+=1;
print(z);
print("++++++++++++++++++++++++++++");
if id.enemycheck_initial=0 then {
id.enemycheck_initial=1;
id.enemiesexist_initial=instance_exists(obj_enemy);
}
deactivateenemies();
instance_activate_object(obj_cave_bigdoor);
if id.enemiesexist_initial=false then { //no enemies here in the first place
//blah
} else {
//blah
}
0 ,
++++++++++++++++++++++++++++ ,
2 ,
++++++++++++++++++++++++++++ ,
0 ,
++++++++++++++++++++++++++++ ,
0 ,
++++++++++++++++++++++++++++ ,
2 ,
++++++++++++++++++++++++++++ ,
0 ,
++++++++++++++++++++++++++++ ,
etc
No matter if I put the code in Begin, Normal or End Step, results are inconsistent. In an even more lulzy turn of events, functions like instance_number() don't work at all (always returns zero), hence the with statement in the beginning of the code. Executing this code every few steps instead of every step doesn't change anything, I tried that too in the ~10 hours I wasted trying to decipher this behavior.
My butthurt venting, after wasting so many hours, culminates into the following questionnaire:
- Why is this instance activation/deactivation behavior undocumented?
- Is the only usefulness of those functions to simply do an instance_deactivate_object() / instance_activate_region() for the view every few steps? Why is it impossible to make them work consistently in another section of our code since apparently they don't happen instantaneously?
- How come that, when doing some positioning calculations eg for an animal, if I call instance_deactivate_object() for a specific instance, do my stuff, and then reactivate said instance, it works OK? Why can't I do the reverse, eg Activate first then Deactivate, if for example I want to count something?
- Why is this instance activation/deactivation behavior undocumented?
- Why when activating instances then immediately calling instance_number() or instance_exists() returns zero? Do you even understand what functionality and possibilities are crippled because apparently activation/deactivation runs in some process that may or may not be synced to the actual game?
- Are you aware that, as they are programmed now, activation/deactivation cause problems like flickering on the y-axis in conjuction with depth=-y? Do you know that activating/deactivating can mess up collision masks in large areas with many objects, and you have to reassign those masks manually after reactivating by writing the following, award-winning, magnum opus of human thought, code?
Code:
var t=mask_index; mask_index=<whatever>; mask_index=t; //mind=blown
- Aside from a few flagship games that have gotten away with it, do you know how hard it is to work around these stuff when making a large game? Do you even know how many hours I have wasted, constantly questioning my code while it was the engine the entire time? Are you really satisfied that you abandoned 1.x, as per your usual tactics, to present an even buggier version (for which you amply charge money nonetheless), which you will no doubt ditch again in a few years for version 3 and so on?
- Why is this instance activation/deactivation behavior undocumented?
- I can and I will work around this problem, like I did with all the other problems the engine threw at me. But why do I have to do so in the first place?
Last edited: