Create item. This is how you should create new TInventoryItem instances. It is analogous to TCreatureResource.CreateCreature, but now for items.
Note that the item itself doesn't exist on a 3D world — you have to put it there if you want by TInventoryItem.PutOnWorld. That is because items can also exist only in player's backpack and such, and then they are independent from 3D world.
You usually define your own item resources by adding a subdirectory with resource.xml file to your game data. See [https://castle-engine.io/creating_data_resources.php] and engine tutorial for examples how to do this. Then you load the item resources with
Sword := Resources.FindName('Sword') as TItemResource;
where 'Sword' is just our example item resource, assuming that one of your resource.xml files has resource with name="Sword".
Now if you want to add the sword to your 3D world by code:
Because TInventoryItem instance is automatically owned (freed) by the 3D world or inventory that contains it, a simplest example how to add an item to your 3D world is this:
Sword.CreateItem(1).PutOnWorld(SceneManager.LevelProperties, Vector3(2, 3, 4));
This adds 1 item of the MyItemResource to the 3D world, on position (2, 3, 4).
If you want to instead add sword to the inventory of Player, you can call
This assumes that you use SceneManager.Player property. It's not really obligatory, but it's the simplest way to have player with an inventory. See engine tutorial for examples how to create player. Anyway, if you have any TInventory instance, you can use TInventory.Pick to add TInventoryItem this way.