S
stepup2000
Guest
Im trying to make a render distance (turning off all the instances when they are to far away)
code:
//create
alarm_set(0, 30);
instance_deactivate_all(true);
//alarm 0
alarm_set(0, 30);
instance_activate_region(x - 200, y - 200, x + 200, y - 200, true)
instance_deactivate_region(x - 200, y - 200, x + 200, y - 200, false, true)
i didnt have the time to test this but this should work. now the problem is that at the beginning of the game there will be a huge frame drop because the game has to deactivate tons of objects. i had the idea to fix this with:
alarm 1
alarm_set(1, 5);
inst = instance_nearest(x, y, all)
if distance_to_object(inst) > 200 {
instance_deactivate_object(inst)
}
but the probem with this is that this takes a really long time. does anyone have any idea how to optimize this and fix the problems? thanks in advance.
code:
//create
alarm_set(0, 30);
instance_deactivate_all(true);
//alarm 0
alarm_set(0, 30);
instance_activate_region(x - 200, y - 200, x + 200, y - 200, true)
instance_deactivate_region(x - 200, y - 200, x + 200, y - 200, false, true)
i didnt have the time to test this but this should work. now the problem is that at the beginning of the game there will be a huge frame drop because the game has to deactivate tons of objects. i had the idea to fix this with:
alarm 1
alarm_set(1, 5);
inst = instance_nearest(x, y, all)
if distance_to_object(inst) > 200 {
instance_deactivate_object(inst)
}
but the probem with this is that this takes a really long time. does anyone have any idea how to optimize this and fix the problems? thanks in advance.