Help deactivating objects not in the view? [SOLVED]

Hudsonius

Member
I'm using a very large room with hundreds of objects in it, and I needed to deactivate objects not in the view, so I used:
Code:
instance_activate_region(vx,vy,vw,vh, true)
instance_deactivate_region(vx,vy,vw,vh,false,true)
In the controller object. (I set vx, vy, vw, and vh to be view x, view y, etc.) However, the deactivated region isn't moving with the player's camera. All the views match to zero, so the controller isn't setting it to a different view. If the player goes out of the region deactivated, he will be deactivated too. Any help?
 

Simon Gust

Member
You say you set your variables like this (GM:S 1.4 code)
Code:
vx = view_xview[0];
vy = view_yview[0];
vw = view_wview[0];
vh = view_hview[0];
Are you updating these variables every step?
 

Hudsonius

Member
You say you set your variables like this (GM:S 1.4 code)
Code:
vx = view_xview[0];
vy = view_yview[0];
vw = view_wview[0];
vh = view_hview[0];
Are you updating these variables every step?
Thanks! I overlooked this and used this in the create event. It is working now. Here is the code I was using for the views though:
Code:
vx = camera_get_view_x(view_camera[0]);
vy = camera_get_view_y(view_camera[0]);
vw = camera_get_view_width(view_camera[0])
vh = camera_get_view_height(view_camera[0])
 

Simon Gust

Member
Thanks! I overlooked this and used this in the create event. It is working now. Here is the code I was using for the views though:
Code:
vx = camera_get_view_x(view_camera[0]);
vy = camera_get_view_y(view_camera[0]);
vw = camera_get_view_width(view_camera[0])
vh = camera_get_view_height(view_camera[0])
Views were changed in GM:S 2, but that looks probably right.
 
Top