• 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!

GameMaker "Resetting" objects outside camera view

L

L1NDHOLM

Guest
Hello, i'm wondering what the best way could be to make objects that go outside my view_camera[0] to "reset".

For example if im in a 2d platformer and move forward (to the right) and kill some enemies & run past some enemies then go backwards (left) i want them to respawn where i put them in the room when i designed it.

My current solution only deactivates objects in a specific layer when outside my view_camera[0], like this:

Code:
inst_lay_id = layer_get_id("Instances");
instance_deactivate_layer(inst_lay_id);
var cam, cleft, ctop, cw, ch;
cam = view_camera[0];
cleft = camera_get_view_x(cam);
ctop = camera_get_view_y(cam);
cw = camera_get_view_width(cam);
ch = camera_get_view_height(cam);

instance_activate_region(cleft, ctop, cw, ch, true);
Thanks.
 
Top