Legacy GM objects not deactivated

Y

Yvalson

Guest
so objects outside of the view and it's padding get deactivated. this works if I do it every frame so I want to do it only when the walked a certain amount of pixels (256 in this case) but for some reason now everything keeps being activated. code:

Code:
else if(view_xview[0] - lastxview > difference || view_xview[0] - lastxview < -difference || view_yview[0] - lastyview > difference || view_yview[0] - lastyview < -difference){
    if(!Obj_Mognorian_Spawner_Forest_1.Arena_Created){
        lastxview = view_xview[0]
        lastyview = view_yview[0]
        instance_deactivate_region(view_xview[0] - 256, view_yview[0] - 256, 1538, 976, false, true)
        instance_activate_object(Obj_Mognorian_Spawner_Forest_1)
        instance_activate_object(Obj_Ekirth1)
        instance_activate_object(Obj_Samonith1)
        instance_activate_object(Obj_ForestBlockade)
        instance_activate_object(Obj_DayNight)
        instance_activate_object(Obj_Rain_Cont)
        instance_activate_object(Obj_Sandstorm_Cont)
    }
}

//difference = 256
 

TheouAegis

Member
Because you're deactivating everything outside the view but then activating everything regardless of its position in the view.

Deactivate everything as a whole, then reactivate everything inside the view, then reactivate anything that needs to stay activated even outside the view.
 
Y

Yvalson

Guest
Because you're deactivating everything outside the view but then activating everything regardless of its position in the view.

Deactivate everything as a whole, then reactivate everything inside the view, then reactivate anything that needs to stay activated even outside the view.
wow thanks and how can I do it right then?
 

TheouAegis

Member
if abs(lastxview - view_xview[0]) + abs(lastyview - view_yview[0]) >= 256
{
lastxview = view_xview[0];
lastyview = view_yview[0];
instance_deactivate_all(true)
instance_activate_region(view_xview[0]-256,view_yview[0]-256, view_wview[0]+512,view_yview[0]+512, true);
}
 
Y

Yvalson

Guest
if abs(lastxview - view_xview[0]) + abs(lastyview - view_yview[0]) >= 256
{
lastxview = view_xview[0];
lastyview = view_yview[0];
instance_deactivate_all(true)
instance_activate_region(view_xview[0]-256,view_yview[0]-256, view_wview[0]+512,view_yview[0]+512, true);
}
not working for me all objects still appear outside of the view and outside of the padding

(edit)
nvm removed 1 part at the top that activated all the instances regardless and now its working
 
Last edited by a moderator:
Top