Instance Deactivation and Views

S

steskle

Guest
Hello everyone.
I'm having problems in regards of instance activation/deactivation.

Back in GM8, I've always done this.

I have an instance called "camera" which, in the step event, controls the enemy activation/deactivation.
obj_deactivateme is the parent of object for all enemies (it's actually the parent of the enemies' parents), but it still works.

instance_deactivate_object(obj_deactivateme)
instance_activate_region(view_xview[0]-16,view_yview[0]-16,view_wview[0]+16,view_hview[0]+16,true)
For some reason, in GMS2 this doesn't seem to work.
The instances are indeed deactivated, but are not reactivated once they step into the activation region.
Moreover, the instances that are created already in the region are not deactivated once they step out of it.
I've checked my original GM8 files and all seems to work correctly.

Other than that, I've also noticed, by adjusting the x offset of the view juuust a bit (in the room editor), the game acts as if the view doesn't move. The "camera" does, but the activation region doesn't follow the view, but instead remains to the starting coordinates of the view.

So... what is happening?
 

RangerX

Member
First of all, your way of doing this is taxing more than it should.
And I think it doesn't work to activate/deactivate in the same step anymore.
What you should do is the following:

- Your parent could have an "outside view" event with the deactivation code inside.
- Your camera object or whatever object the cam follows could activate a region (probably the view size and position) each 2 or 4 steps. (maybe even more if your game doesn't scroll too fast)
 
S

steskle

Guest
I actually just solved it.

Back in GM8, I just used view_xview[0] etc.
Whereas in GMS2 things changed:

var view_wview = camera_get_view_width(view_camera[0]);
var view_hview = camera_get_view_height(view_camera[0]);
var view_xview = camera_get_view_x(view_camera[0);
var view_yview = camera_get_view_y(view_camera[0]);/quote]
 
Top