#Prefab/ Scriptable Objects to the rescue

1 messages · Page 1 of 1 (latest)

covert ridge
#

Can you elaborate? I've looked into Scriptable Objects but they seem to be pretty distant from prefabs/GameObjects, so I couldn't figure out how to use them to define a set of prefabs that I could sequence through

rare ravine
#

Scriptable Objects are single instances of prefab, you use that information to instantiate the object with behaviour embedded in it. Your object should include the necessary information for farm growth, E.g. From seeds -> plant -> etc.

I'd start with a prefab first, make sure that you can spawn the seeds first, then look into scriptable objects afterward to make customization easier later.

Avoid using string to find the object you need to reference, instead, objects should have their own describe behaviour within the nested parent itself. I'm trying to figure out why you need the string when you can rely on having a single game object (Can just be an empty game object that holds position/rotation/scale, and child under that object would be the individual stage of your farm growth) - Script on that parent object would manage the state of each other gameobject in it's nested structure.

covert ridge
#

The string thing would be nice because then I could add new crops and change stages or drops or whatever from a simple config file. I've done it with an SDL2 game before - can add crops with full functionality in just a few lines of text and the needed sprites.

Here I feel like I've got to hardcode everything about it - I feel like I'm missing something huge but I just can't figure out how to dynamically swap models without manually storing the GameObjects I'm swapping between

#

Idk, I'm still just not grokking it

#

e.g. like here, I've manually specified the tilled and untilled soil models

This doesn't seem scalable to a bunch of crops and stages though

rare ravine
#

So - It's not the same as C++, finding object using string is expensive as it would have to query data. You'd perform faster if you have direct reference to the object itself.

Having that said, you can have a class on the parent object of say "Plant" which describe a list of step for the seed to grow. Each element would have their own class to describe the current state of the plant's lifetime.

#

that list can be dynamically change however you want it to be, as it doesn't have to be fixed.