• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Discussion Any plans to make instance activation_deactivation instant?

vdweller

Member
As has already been discussed in this thread,

https://forum.yoyogames.com/index.p...ce-activation-deactivation-shenanigans.47238/

Instance activation/deactivation does not happen instantaneously. Specifically,
Activation then Deactivation works if Activation happens, say, in the Step Event and Deactivation in the End Step event.
The reverse, Deactivation then immediately Activation seems to work. I haven't thoroughly tested if deactivation actually happens instantaneously.

Is there any chance you could alter this behavior and make these functions have immediate effect?

To illustrate an example, with the current behavior, we get this:
1) Some instances are activated and some are deactivated due to prior processing.
2) Suppose that I want to temporarily activate all instances of a kind, for example to count all enemies in a room regardless of their active/inactive status.
3) This doesn't work as activation does not take place immediately.

This is just an example. I am not looking for workarounds for this specific case.

@rwkay @Nocturne Any insight on this? Could this happen in a future update?
 

csanyk

Member
Another thought on this: Would it be of interest to anyone to add Activated and Deactivated as Events? Similar in concept to Create and Destroy Events, they would fire their code when an instance is Activated, or just prior to it being Deactivated.

I don't use activation/deactivation all that much, but I can see it being potentially useful.
 

FrostyCat

Redemption Seeker
Another thought on this: Would it be of interest to anyone to add Activated and Deactivated as Events? Similar in concept to Create and Destroy Events, they would fire their code when an instance is Activated, or just prior to it being Deactivated.

I don't use activation/deactivation all that much, but I can see it being potentially useful.
It would be of interest to anyone who'd use it, but also not strictly dependent on action from YoYo.

Set aside 2 user events for activation/deactivation, then use scripts to bundle calls to those events with activation/deactivation functions.

Example:
Code:
///@function deactivate_object(obj)
with (argument0) {
  event_user(7);
}
instance_deactivate_object(argument0);
Code:
///@function activate_object(obj)
instance_activate_object(argument0);
with (argument0) {
  event_user(8);
}
Edit: Fixed wrong order on activate.
 
Last edited:

The-any-Key

Member
deactivation actually happens instantaneously
If the instance was active in the beginning of the step/tick you can temporary deactivate it and re-activate it in the same step.
Ex you can do this:
Code:
// Deactivate outside view
with obj_mine
{
   // Say this will deactivate 5 of 10 instances in room
   if x>outside_view
   {
      Add_to_list[c]=id;
      c+=1;
      instance_deactivate_object(id);
   }
}
// Run check for all inside view
with obj_mine
{
   will only loop the 5 that is active
}
// Re activate again
loop Add_to_list and run instance_activate_object(Add_to_list[i])...
// Loop all 10 again
with obj_mine
{
   will only loop the 10 instances
}
However. If the instance is de-active when the step/tick start. You need to activate it, wait for the next step, and then it will work with the "with obj { }".
Ex:
Code:
// Run check for all inside view (there are 10 in total and 5 is deactivated from the beginning of the step/tick)
with obj_mine
{
   will only loop the 5 that is active
}
// Re activate again
loop Add_to_list and run instance_activate_object(Add_to_list[i])...
// Run check for all inside view (there are 10 in total and 5 is deactivated from the beginning of the step/tick)
with obj_mine
{
   will only loop the 5 that is active, the 5 will be active in the next step/tick
}
My guess is that when an instance is de-active when the step start, GM don't add it to it's internal event handler list (a list where all instances that will be processed).
And this is good. All de-activated instances will be skipped and your game run faster.

But if you have them in the event handler, even if they are deactivated. This would allow you to instantly activate them and use them in a "with obj { }".
However, this would mean they need to be looped in the event handler and will be partly processed. So you will lose the speed you gain when deactivate an instance. And we don't want that.

It may be possible if the handlers is working differently. But it might be a big job to change the architecture of GMs internal instance handling, just to get this working.
 

vdweller

Member
@The-any-Key I am not sure why you wrote this reply. I mean, constitutionally speaking, I guess you have the right to do so, but it has nothing to do with the initial post, in which not only I do highlight how the thing actually works right now, but I also explicitly state that I am not looking for workarounds (I have already implemented them since I empirically know how the thing works).

The post was aimed primarily at people involved with development of GM:S2 and about discussing the potential and/or limitations of making instance activation/deactivation have immediate effect. Your explanation about why it is the way it is could be p. much close to the truth though.
 

csanyk

Member
@The-any-Key I am not sure why you wrote this reply. I mean, constitutionally speaking, I guess you have the right to do so, but it has nothing to do with the initial post, in which not only I do highlight how the thing actually works right now, but I also explicitly state that I am not looking for workarounds (I have already implemented them since I empirically know how the thing works).

The post was aimed primarily at people involved with development of GM:S2 and about discussing the potential and/or limitations of making instance activation/deactivation have immediate effect. Your explanation about why it is the way it is could be p. much close to the truth though.
You might not have needed The-Any-Key's workaround, but others reading this thread who don't have a workaround might find it valuable :)
 
Top