Copy of Item without instanticade on scene.

Hi, i have little problem. I tryed to make equipment but i dont know how to make copy of GameObject.

public GameObject[] item = new GameObject[35];

public void adding(GameObject obj)
        bool found = false;
        for(int i = 0; i<35; i++)
            if(item *== null)*

item = obj;
found = true;
if (found == false)
obj.transform.position = GetComponent().cam.transform.position + GetComponent().cam.transform.forward;
obj.transform.parent = null;
i want to have copy of Item but without instanticade on scene. But i got message “Missing Object”.

Make it a prefab and drop it in your script.

I think that’s what you’re asking.

GameObjects have a transform component that defines their position and rotation in the scene and in the scene hierarchy and they can optionally have other components like renderers that define how they are drawn on the screen.

If your items often exist in the game in a way that these things are irrlevant/not needed/not wanted (all you need is their values) they probably shouldn’t be stored as GameObjects.

If you want to tweak item values in inspector, you could use ScriptableObjects as the source of your data and instantiate those to make copies or depending on your needs, even create some factory methods (e.g. in the ScriptableObject) that pull the needed values from the SO into a normal C# class instance and make copies of those C# classes (for example the C# class could have a constructor that takes in the SriptableObject and pulls some values from it).

When you need to show your items somewhere in the game, you could make and use a MonoBehaviour that can take your SO/item data class and configure itself graphically using the SO’s data

The unity tutorial explains how you can easily create scriptableObjects into your project. You can make multiple assets using the same “Item” ScriptableObject that you program. Then just name the created asset files “sword”, “shield” etc. in the project view, tweak the values and drag those objects to wherever you need references to sword or shield stats.