top of page
Search

Managing Objects in Large Rooms : Easy Performance Optimization

In large GameMaker rooms with high-resolution assets, too many active objects (like trees, walls, or buildings) can slow down your game. A great way to optimize performance is by activating and deactivating objects based on their position relative to the camera's view.


Image source :  Vampire Survivors
Image source : Vampire Survivors

Why Activate/Deactivate Objects?

By deactivating objects outside the player's view and activating those near the camera, you can save processing power. This keeps only essential objects active and reduces unnecessary load.


How It Works:

  1. Use an Alarm: Set an alarm to run every 60 steps to manage activation and deactivation.

  2. Deactivate Unnecessary Objects: Objects outside the camera's view (e.g., trees, buildings) are deactivated.

  3. Activate Nearby Objects: Objects just outside the camera's view are activated.





Code Example:


// Set the alarm to trigger every 60 steps
alarm[0] = 60;
// Deactivate non essential objects outside the camera's view
with (o_treePar) {
    instance_deactivate_object(id);  // Deactivate trees
}
with (o_buildingPar) {
    instance_deactivate_object(id);  // Deactivate buildings
}
// Activate objects around the camera / middle of your view area
instance_activate_region(left, top, width, height, inside);

Why This Works:

  • Deactivation by Parent: Only deactivate non-essential objects (trees, buildings), ensuring important objects (like controllers) stay active.

  • Activate Nearby Objects: Activate objects just outside the camera’s view to ensure smooth transitions.


Documentation and Reference:


Conclusion:

By using activation and deactivation based on the camera's view, you can keep your game running smoothly even with many objects. This method reduces unnecessary load and optimizes performance.

 
 
 

留言


© 2022 Darkware

bottom of page