Sponsored By
Liam Simmons, Blogger

August 6, 2015

2 Min Read

This was originally published on https://mutinyproductions.wordpress.com/. Our team is working on a FPS designed for short play sessions.

In the current project we are working on (Dawnbreak) we are intending to target a large range of platforms on release. This is primarily to gain experience on these platforms, and to maximise our player base.

Designing a game that can handle different platforms requires some thought to be how we handle textures in game. Our game requires guns and guns create bullet holes. Each of these bullet holes is a small texture painted on to the environment at run time. Over time, all those bullet holes add up to a huge amount of memory for something that really only added a moment of impact.

To solve this I created  Object Manager that cleans up and removes bullet holes when too many get created, allowing for players to continue to have an impact on the environment while not sacrificing too many resources.


using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class ObjectManagement : MonoBehaviour {

    public int MaxNumberOfObjects = 100;
    List< GameObject> ObjectList = new List< GameObject>();

    void ManageObjects()
    {
        if(ObjectList.Count > MaxNumberOfObjects)
        {
            GameObject tempObj = ObjectList[0];
            ObjectList.RemoveAt(0);
            Destroy (tempObj);
        }
    }

    public void AddObject(GameObject _object)
    {
        ObjectList.Add(_object);
        ManageObjects();
    }
}

The manager is inherently simple to implement and use. A developer can set the maximum number of objects in the editor or set this in run time as a way to gain resources if a game gets too heavy. Call


AddObject(_object)

and pass the GameObject wishing to be managed as a parameter. An easy way to manage anything in your scene that gets spawned with regularity!

Liam Simmons ~Software Engineer at Mutiny Productions. Check us out on Twitter @MutinyProds

Any advice/criticisms most definately welcome!

Read more about:

Featured Blogs

About the Author(s)

Daily news, dev blogs, and stories from Game Developer straight to your inbox

You May Also Like