top of page

Part 4. Prefab Structure and Dependencies.

  • Foto van schrijver: Sam Walet
    Sam Walet
  • 3 jun 2022
  • 2 minuten om te lezen

For the sake of structure I have chosen to ignore a few things in the previous sections that I intend to cover here. Namely how I also changed the source and detector system to be more flexible and incorporated the modifiers which handled the reactions to the change of values. That’s because the changes in these systems all have to do with prefab structure and dependencies.

So to start I organized the prefab the way i always do, an empty gameobject which contains two objects Object_Logic where all the scripts go and Object_Visuals where the art assets go. On the Object_Logic object we have the Object script which manages sources, detectors and modifiers. Underneath it we have three more empty gameobject under which the sources, detectors and modifiers will be housed.


By committing to this structure we will be able to find all of these scripts relative to each other. So when the object awakens we simply use Transform.Find to find these parent objects and gather all the detectors, sources and modifiers gathered under them. But we can do better because this requires designers to parent individual detectors, sources and modifiers under these objects for everything they want the object to do. What if we could make it so all of this can be done from the Object script?


Seeing as we have a list of all properties and know whether they are inherent or not we can do this much simpler. We can simply add detectors for all properties on awake and add a source for any non inherent property that has a base value above 0. Using the same tricks we used before we can make a serializable class containing all the information we need to create a source and instantiate these for any property that gets a source on awaken.



For the modifiers it’s okay to have to manually add them under the Modifier parent object since every modifier has unique settings and thus instantiating these at runtime would quickly become unwieldy but the sources and detectors have now been reduced to a couple of lists in the Object class.









 
 
 

Recente blogposts

Alles weergeven
Final Part. Variables

Last but not least I would like to spend a little time on variables. You should be conscious of which variables you show in the inspector...

 
 
 

Opmerkingen


Post: Blog2_Post

©2022 door Sam Walet. Met trots gemaakt met Wix.com

bottom of page