• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

[SOLVED]activate/deactivate flicker

K

kaerpaenen

Guest
Hi! I have a quick question about a problem I'm having.

There's a fairly big world in the game I'm making, so I'd prefer to use the deactivating and regional activating for most of my objects, to optimize the performance. This works really nicely for my trees! But whenever I apply this to my enemyobjects, or some other objects, they flicker the whole time they are on the screen. Not sure what is causing this, any ideas?
 

RangerX

Member
Its because they keep being activated and deactivated constantly.
Can you please show us all of you activation/deactivation code please?
 
K

kaerpaenen

Guest
This is the deactivation code on trees and enemyobjects
Code:
if x < camera_get_view_x(obj_camera.camera) || x > camera_get_view_width(obj_camera.camera) || y < camera_get_view_y(obj_camera.camera) || y > camera_get_view_height(obj_camera.camera)
    {
    instance_deactivate_object(id);
    }
This is the activation code on the player
Code:
instance_activate_region((camera_get_view_x(obj_camera.camera)-64),(camera_get_view_y(obj_camera.camera)-64),(camera_get_view_width(obj_camera.camera)+128),(camera_get_view_height(obj_camera.camera)+128),true);
The thing is, the trees don't flicker, but the enemies do.
 

RangerX

Member
You activate a region that is larger than you screen while your objects there checking if only their X and Y position is not on cam.
This means when you see your object there but its X still is outside the cam, it will flicker from being activated and deactivated constantly.

Try using the "outside view" event on your objects and simply put this code inside:
instance_deactivate_object(id);

Then activate a region that is precisely the cam size.
 
K

kaerpaenen

Guest
You activate a region that is larger than you screen while your objects there checking if only their X and Y position is not on cam.
This means when you see your object there but its X still is outside the cam, it will flicker from being activated and deactivated constantly.

Try using the "outside view" event on your objects and simply put this code inside:
instance_deactivate_object(id);

Then activate a region that is precisely the cam size.
Thank you, this works. I swear I fiddled with Outside view sometime before, but I guess I did something wrong. Oh well, thanks again!
 
Top