Get the latest Education e-news
 
  • Orchestrating Gameworlds: A Prefab Primer

    [07.10.18]
    - Nathan Cheever

  • Slicing Up Scenes

    How do you set up scenes to use sectors? How do you work on them? How should logic be arranged in them? Before we talk about sectors, we need to understand how the scene played in the game (the Master, Main, or Persistent scene) is organized. Each scene consists of four basic components:

    Applying this concept to sectors, we can create a framework for maximum flexibility to add (or remove) parts of the master scene without impacting the master scene itself. Each component can become a prefab for each sector.

    Some prefabs don't have to be exclusive to a sector; they can span several sectors. This allows one person to check out a prefab to have access to the whole scene. The disadvantage is when sectors are move around in the master scene requiring contents to be moved manually to their new position.

    Editing Prefabs

    Two methods of prefab editing should exist:

    1. Edit the prefab in a new scene.
    2. Edit the prefab in the current scene.

    By editing the prefab within the current scene, it removes switching back and forth between scenes to see your changes.

    Deltas

    By their nature, prefabs placed in scenes are instances of the original prefab. If changes are made to the prefab, those changes propagate to all copies in every scene. This can be helpful for example, if you want to change a texture or a light across a hundred copies. You might however only want one small change. You need a way to remember those individual changes, instead of creating a new prefab for each change, exponentially increasing the number in the game library.

    This can be solved by tagging any differences and re-applying those differences after changes to the original is made. Technically speaking, values unique to any type of object are stored in the parent prefab or scene file to override its original values. When a change to the original is made, all copies reflect that change unless the value has been overridden on the instance.

    An "Allow Deltas" action provides a way to maintain these overrides. With a prefab selected and "Allow Deltas" on (set to true), unique values will be accepted and maintained. If "Allow Deltas" is turned off, all values are reset to their default.

    To prevent the need to open prefabs, another option is enabling Child-picking. This ignores prefab containers and directly picks any object in view, no matter how deep they're nested. Normal editing of prefabs should be outlined in red to indicate changing this one instance will change all instances of it. With Deltas on, objects inside prefabs should be outlined in cyan, letting you know any changes will only be applied to the selected object.

    Conclusion

    Today's games involve thousands, if not millions, of objects. Managing all that content, making quick changes, and sharing team efforts, becomes a massive burden without a prefab system in place. If you want to spend more time discovering what's exciting about your game and less time playing 52,000 card pickup, then take the time to invest in a proper prefab feature.

    You can find more posts like this on my website at CuriousConstructs.com.

Comments

comments powered by Disqus