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

GML How do I deactivate objects not in my players view?

  • Thread starter Deleted member 16767
  • Start date
D

Deleted member 16767

Guest
This does not work


In player step event:
Code:
instance_deactivate_region(view_xport[0]  view_yport[0], view_wport[0], view_hport[0], false, true); //deactiveate all outside view 
instance_activate_object(obj_Enemy_1_Start_19); //save this object from being deactivated
 
D

Doulos

Guest
I use dnd, but it would look like this is psuedocode...

Get players view bounds, assuming thos are yoru inputs here.
Apply to All
if x < other.view_xport[0] or x > (view_xport[0] + view_wport[0]) or y < view_yport[0] or y > (view_yport[0] + view_hport[0])
then deactivate

according to the manual, I am assuming your instance_deactivate_region() should work though.
Your view variables look valid too, to me.
 

TsukaYuriko

☄️
Forum Staff
Moderator
port, as in view_xport, refers to the view port, or how the view is being rendered to the screen (or the application surface).
view, as in view_xview, refers to the view, or which portion of the room the camera sees.

You're looking for the latter.
 
D

Deleted member 16767

Guest
Thank you @Doulos and @TsukaYuriko

The game runs a lot smoother now! I deactivated everything in the Outside View event.

But I have a minimap where I have alt + clicked the solid wall all around the tileset walls. I don't see them disappearing and reappearing on the characters view.
 

TsukaYuriko

☄️
Forum Staff
Moderator
Tiles are not instances and will not be deactivated by instance deactivation.

If you want to optimize tile drawing, check out surfaces in the manual - the basic idea for this is to draw all tiles to the surface once, only redrawing the surface if the player leaves the area that is currently drawn to the surface, then only draw the surface from that point on and hiding the tiles. It massively cuts down on the amount of draw calls and should improve performance.
 
D

Deleted member 16767

Guest
@TsukaYuriko I solved it with the minimaps script code.

Code:
if distance_to_object(obj_Player_Wizard) < 1200
    {
        draw_set_alpha(1)
    }
  
    if distance_to_object(obj_Player_Wizard) > 1200
    {
        draw_set_alpha(0)
    }
}
 

GMWolf

aka fel666
Tiles are not instances and will not be deactivated by instance deactivation.

If you want to optimize tile drawing, check out surfaces in the manual - the basic idea for this is to draw all tiles to the surface once, only redrawing the surface if the player leaves the area that is currently drawn to the surface, then only draw the surface from that point on and hiding the tiles. It massively cuts down on the amount of draw calls and should improve performance.
Hmmm, is that still the case in GMS2?
I mean those tiles are a single draw call... Even a single piece of geometry!
 
D

Doulos

Guest
Not wanting to side topic here, but.
Are we saying using many small tiles are not efficient?
Should we just create a smaller number of larger objects that do almost nothing, which we can then enable / disable outside of view?
or Perhaps I just do not understand your comment @TsukaYuriko ?
 

TsukaYuriko

☄️
Forum Staff
Moderator
@GMWolf:
I was discussing this matter in-depth on the old GMC: http://gmc.yoyogames.com/index.php?showtopic=631986

To which extent this holds true in GMS2 is not something I know or have tested, but you're welcome to test this for yourself and share the results. Since the old view system is being used instead of the camera system, I figured this was about 1.x - on a second thought, it can technically still be used in GMS2, though... so I probably should've clarified that first. My bad.

@Doulos:
I'm not talking about big tiles vs. small tiles, I'm talking about tiles vs. surface. The rest is explained in the topic I linked above.
 
E

Edwin

Guest
@TsukaYuriko I solved it with the minimaps script code.

Code:
if distance_to_object(obj_Player_Wizard) < 1200
    {
        draw_set_alpha(1)
    }
 
    if distance_to_object(obj_Player_Wizard) > 1200
    {
        draw_set_alpha(0)
    }
}
Changing their alpha don't deactivate them.
 
Top