zampa
Member
So i am trying to check if i want to activate or deactivate objects every 30 frames
with this code:
but it doesn't deactivate them all
I tried putting 4 objects in the room and the running a instance_number for that objects and it tells me that 2 are active even if they should be all deactivated
so i ran the debugger on that part and i found out that var num = instance_number(obj_platform_falling); this variables returns 4,
the correct number of objects, but with instance_find when i is 2 it returns -4 like the second object doesn't even exist
I don't know what to do
with this code:
GML:
count_activate++;
if(count_activate >= 30){
count_activate = 0;
var right = x + global.iw/2 + 180;
var left = x - global.iw/2 - 180;
var top = y - global.ih/2 - 180;
var bottom = y + global.ih/2 + 180;
instance_activate_object(obj_platform_falling);
var num = instance_number(obj_platform_falling);
if(num != 0){
for(var i = 0; i < num; i ++){
var inst = instance_find(obj_platform_falling,i);
if(inst != -4){
if(!point_in_rectangle(inst.x,inst.y,left,top,right,bottom)){
instance_deactivate_object(inst);
}
}
}
}
}
I tried putting 4 objects in the room and the running a instance_number for that objects and it tells me that 2 are active even if they should be all deactivated
so i ran the debugger on that part and i found out that var num = instance_number(obj_platform_falling); this variables returns 4,
the correct number of objects, but with instance_find when i is 2 it returns -4 like the second object doesn't even exist
I don't know what to do