Jump to content

Overthinking is >still< a killer.


Recommended Posts

  So off and on for a few weeks I've been toying with having a unique identifying value for each object in the scene. A big part of this is just being able to guarantee uniqueness and to keep the data that guarantees that information as small as possible. I tried a number of things, some involving pretty complicated editor scripting, and ultimately in the end I felt like the effort wasn't really paying off.

  I was making something that would not be fun to maintain and might be hiding secret evils in my future.

  I decided today that I would instead have a catalog (well Artifact) that tracks every item in the world. I specify item here, because we don't really care about things that our actors can't interact with. This catalog will track the position of the item, the unique ID assigned to that item, the unique ID of that Item's type (food, furniture, etc), and finally an unsaved reference to all the components on the item.

  This last reference gives us access to the gameobject, the transform, and all the components we add to it which is very helpful! Something I need to do is have all my items have a base class that they inherit from. There is no real reason to not have that as an item is an item. Some are consumable, most are interactable, but at the end of the day an item is an item. It sounds like a simple concept but I haven't needed to do it yet, so I hadn't done it.

  That's kind of the gotcha, really, with knowing a bit too much and yet not knowing enough. You can create complicated solutions to simple problems and in doing so miss the obvious simpler paths. Simpler isn't always better, sometimes it can result in really heavy computation and bog down your experience. But we can't stress about that at the start. We need to experiment and try new things and when systems fall into place and feel right that's when we start to set rules.

  With that in mind I'll be doing some documentation soon that'll cover various things like saving and loading, artifacts, etc. This is in part so that future me doesn't forget how my systems work! But for tonight this was good enough, this was a less fun refactor than most but the end result I think will be great. With a little bit of work (a new action in the state machine) I can add all the objects in the scene to the catalog on start. The one rule is that we'll need to make sure that each asset has a unique position (thus why I track position). If this becomes insufficient we will explore serializable ways to track them.

  The big thing is that these trackable options must carry with the asset at all times. I could probably write an editor script that just iterates through every asset and gives them a unique integer, and then that is stored. Moving the object around wouldn't change that. New objects would just take whatever that index value is and add one to it. This likely would be sufficient, and would only limit us to something like 2 billion items in the world before we have issues.

  I'll come back to that thought tomorrow perhaps, but it is getting late, per usual.

Link to comment
Share on other sites

×
×
  • Create New...