-
Notifications
You must be signed in to change notification settings - Fork 0
Object Pooling
A script objectPooling and object have been made for pooling objects to prevent items that are constantly created in the factory to need to be constantly deleted and initiated which can cause performance issues.
Instantiating Objects: The object that normally spawns objects into the game now calls the spawnObject method which takes the same parameters as the built in Instantiate method. This method then looks to see if pools for that objects exists. If they do not, it creates both an inactive and active pool based on that object's name. Now when trying to spawn an object it looks to see if there are any inactive copies of that object in that object's inactive pool. If there are objects in the inactive pool, it sets that object's position and rotation based on the method's parameters, makes it active, and puts it into the active pool. If there are no objects in the inactive pool, a new object is instantiated and placed into the active pool.
Deleting Objects: Now instead of deleting an object, the storeObject script can be used instead. This script will inactivate the object and add it to that object's inactive pool for the spawnObject script to pull from.
Pre-instantiating Objects: Using the PoolObjects script, we can now also pre-instantiate objects for example during a loading sequence for a level we can pool many inactive objects within inactive pools that we expect to be used during the level. This way objects will be instantiated less while the player is actually playing the level which could improve performance.
- Current Branch Descriptions
- Version 1 Game Flow Overview
- Version 2 Game Flow Overview
- Localization and Start Screen Canvas Organization
- Overview of Scripts and Connections
- Machine Scripts
- Order Releases
- Demand
- Stage Controller
- Data Collection
- Video Recording
- Money Tracking
- Quest Systems for Levels and Tutorials
- Object Pooling
- Time Controller
- Forklift Scripts
- OpenAI Assistant Integration
- Ray Casting
- Camera Script
- General Purpose Object Collision