Makinom - Game Toolkit for Unity
  • Features
  • Showcase
  • Guide
    • Documentation
    • Tutorials
    • Extensions
    • API
  • Makinom 1
    • Tutorials
    • Plugins
    • API
  • Support
  • Forum
  • Get Makinom

Guide

Getting Started

  • Introduction
  • First Steps
  • Game Starters
  • Components Overview
  • Upgrading a Makinom 1 Project

Editor

  • Makinom Editor Overview
  • Node Editor
  • Asset Sources
  • Editor Section
  • Base/Control Section
  • Game Section
  • UI Section
  • Templates Section

Features

  • Schematics
  • Dialogue Importer
  • Schematic Nodes
  • Formula Nodes
  • Languages
  • Input Keys
  • Audio and Music
  • Game States
  • Pooling
  • Saving Game Objects
  • Scene Objects
  • Save Games
  • Variables
  • Selected Data

Machines

  • Machine Components Overview
  • Animation Machine
  • Animation State Machine
  • Application Machine
  • Auto Machine
  • Collision Machine
  • Global Machine
  • Interaction Machine
  • Render Machine
  • Tagged Machine
  • Template Machine
  • Tick Machine
  • Trigger Machine

UI System

  • UI System Overview
  • UI Layers
  • UI Layouts
  • UI Boxes
  • HUDs
  • Flying Texts
  • Text Codes
  • Unity UI Module
  • HUDs: Content Providers
  • HUDs: Conditions
  • HUDs: Click Actions

Scripting

  • Scripting Overview
  • Code Extensions
  • Custom Save Data
  • Custom Component Save Data
  • Custom Nodes
  • Starting a Schematic

Advanced Topics

  • Build Troubleshooting
  • Performance Optimizations
  • Home
  • Guide
  • Documentation
  • Features
  • Pooling

Pooling

Table of Contents
  • Using Pooling
    • When to use Pooling
      • Example
  • Game Object Pools
    • Example
  • Pool Component

Game object pooling can be used to increase the performance of your game – learn more about it and when to use it.

Instantiating and destroying game objects can decrease the performance of your game, especially when happening often. This can be reduced by using pooling.

Using Pooling #

Pooling is a technique that will instantiate a pool of game objects when a level was loaded and only enables and disables them afterwards instead of destroying them and instantiating new objects. Usually, this will help increasing the performance, but it can depend on the use case if it actually helps or has negative effects, since having a lot of game objects alive in a pool (even disabled) also costs memory.

When to use Pooling #

As said, pooling costs memory for holding the game objects, but increases the performance by removing the heavy instantiation and destruction of game objects.

You should use pooling when game objects are often created and destroyed, e.g.:

  • firing projectiles, missiles, etc.
  • reappearing enemies

You shouldn’t use pooling for things like level architecture or procedurally generated levels, since those will most likely only be instantiated once and not destroyed until the level ends.

Example #

E.g. the missiles fired by the player’s ship in a vertical space shooter are pooled. The player’s fire rate and the time a missile will be alive result in a maximum of about 15 missiles to be alive at the same time.

The pool size is 20 – this is a good use of a pool, but can also be reduced a bit.

The pool size is 100 – this is a waste of memory.

Game Object Pools #

Game object pools are set up in Base/Control > Game Object Pools.

A game object pool is based on a prefab and instantiates it when a level was loaded. The Start Size of the pool defines the quantity of game objects that will be created at the start of a level. Pools can optionally grow by enabling Can Grow in the pool’s settings – this will add more game objects to the pool when needed and keeps them alive, otherwise game objects exceeding the pool will be destroyed again.

The pooled objects can be used by the prefabs defined in schematics. It’s only used when the prefab is defined as a resource in the schematic’s settings and has using pooling enabled. The prefab in the schematic and the pool must be the same prefab. If that’s the case, spawning and destroying a prefab in the schematic will get a game object from the pool and enable/disable it instead of instantiating and destroying it.

Example #

The prefab missile is pooled with a start size of 10 and can grow.

The player’s control is handled by a schematic using the missile prefab as a resource with Use Pooling enabled. The same prefab as the pooled prefab is used, i.e. spawning this prefab will use a pooled game object.

The level starts and 10 missile prefabs are instantiated and disabled immediately. The player fires missiles, they’re placed at the player’s position and enabled (Spawn Prefab node). When they hit a target or leave the screen, they’re disabled (Destroy Prefab node).

If the pool runs out of missiles, new missiles will be instantiated and added to the pool (i.e. they’ll also be enabled/disabled when used).

Pool Component #

The Pool component is used to add a game object pool to a scene.

It’ll instantiate the selected pool’s prefab when the level was loaded (or when the component is added to the scene in a running game, e.g. spawning pools via prefabs).

Pools are only used in the scene they where added to, i.e. you need to add them to each scene they should be used in.

Share This Article :
  • Facebook
  • Twitter
  • LinkedIn
  • Pinterest
Updated on December 16, 2020
Table of Contents
  • Using Pooling
    • When to use Pooling
      • Example
  • Game Object Pools
    • Example
  • Pool Component
Sitemap
  • Features
  • Showcase
  • Guide
    • Documentation
    • Tutorials
    • Extensions
    • API
  • Makinom 1 Hub
    • Tutorials
    • Plugins
    • API
  • Support
  • Forum
  • Get Makinom
  • Contact
  • Blog
  • ORK Framework
  • gamingislove.com
Categories
  • Makinom 1 (97)
    • Tutorial (97)
      • 2D Platformer (14)
      • 2D Roguelike (8)
      • Breakout (6)
      • How-to (34)
      • Match 3 (6)
      • Schematic (4)
      • Scripting (6)
      • Space Shooter (11)
      • Survival Shooter (8)
  • News (11)
  • Release (68)
Search

© 2015 Gaming is Love e.U.

Disclosure: This site may contain affiliate links, which means I may receive a commission if you click a link and purchase something that I have recommended. While clicking these links won’t cost you any money, they will help me fund my development projects while recommending great assets!