Active Area Not Working [SOLVED]

Gillen82

Member
Hey guys...

Been a while from I was last doing anything in GMS, so I need some help if possible?

I am try to create an active area with a buffer zone around the view. The issue arising is that when applying the value for the buffer zone, the active area is only working within the view, and not beyond.

Looking at the first image, the enemy (red square) is clearly seen, and I'm also drawing a line and calculating the distance between from player to enemy.

upload_2020-2-11_17-59-15.png

The 2nd image now shows, that once the enemy leaves the view, it is deactivated.
upload_2020-2-11_18-1-31.png


I'm looking the instances to be activated beyond the view at all 4 sides, but can't get it working. The code that I have done so far is as follows:


Code:
///Active Area Controls

var vx, vy, vw, vh, buffer;
   
buffer = 320;
vx = view_xview[0] - buffer;
vy = view_yview[0] - buffer;
vw = view_wview[0] + buffer;
vh = view_hview[0] + buffer;

instance_deactivate_all(true); 
   
if(!instance_exists(obj_player))
{ 
   
    instance_activate_object(obj_player);
    instance_activate_object(sys_solid);
    instance_activate_object(sys_camera);
    instance_activate_object(sys_parallax_scrolling);
    instance_activate_object(sys_debug);
    instance_activate_object(sys_screen_manager);
}

instance_activate_region(vx, vy,  vw, vh, true);
Any help would be greatly appreciated!!
 

Simon Gust

Member
The issue may be in view_wview and view_hview, they do not represent the right and bottom edge of your view, they represent the width and height of it.
To get the right edge you have to add view_wview to view_xview.
To get the bottom edge you have to add view_hview to view_yview.
 

Gillen82

Member
The issue may be in view_wview and view_hview, they do not represent the right and bottom edge of your view, they represent the width and height of it.
To get the right edge you have to add view_wview to view_xview.
To get the bottom edge you have to add view_hview to view_yview.
Schoolboy error. That was the issue. Thanks for the quick response!!
 
Top