This question has probably been asked several times in several different ways. I’m fairly new to Unity, but an experienced coder. My question is best described by an example:
I have a Player : MonoBehaviour object and I’d like to be able to associate it with another MonoBehavior (e.g. sword, helm, etc…). The player object has member variables that will hold the instances of those objects (e.g. ISword, IHelm, etc…) I’m having trouble identifying a pattern for instantiating these peripheral objects. I can either Instantiate(…) the object, but then it must be referenced somewhere in the scene hierarchy beforehand OR I can <>.gameObject.AddComponent(), but this will result in a new instance each time.
The latter would make more sense in this case. However, if I wanted to spawn a sword into the world, it seems like I would need some general container to hold it. I guess, that could be a chest or vendor.
I’m just looking for some general guidance here, I’m sure this has been solved 100 times already.
Thanks ahead of time