Hey.
I followed the tutorials for
45-interaction-hud and also for
harvesting-items.
In my game I only changed the interaction hud to the name (%n) of the interactible object and it works perfectly for the combatants, but...
I would like to give the player also a feedback that he can harvest now (or that he is in front of a tree). The problem here is that the tree has no name (%n). When I write hardcoded "Interact". Then the "interact"-label appears.
Since this is a ORK Scripting thread, I do the creation of a tree prefab by code, which has the event file attached.
I am doing this by
Item item = ORK.Items.data [OrkId];
GameObject itemObject = GameObject.Instantiate(item.prefab) as GameObject;
is this good practice?
or is it also possible to spawn items (like combatants as described in the tutorials) by script? (e.g. for a potion, chest,...)
I tried some things out, but always failed at the end:
- using ItemCollector
- using ItemShortCut (itemCollector.AddItem(..))
- trying to create shortcut with itemGain
always had an Object null reference in
ItemCollector.cs:
ShortcutHelper.Add(ref this.itemList, shortcut,
ORK.InventorySettings.itemBoxCollection.useInventoryAddType);
maybe someone can give me a code snippet for spawning item collectors by code :)))
Many thanks.
You can define scene object information (name, description, even different types) in the World section of the editor. Add the information to a game object in your scene using a Scene Object component.
E.g. the interaction HUD's %n text code will also use the name of the scene object.
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
So now I just create for each Orb prefab, tree prefab, ... such a scene object and assign them.
Thank you very much.
But still, may be you can give me a hint for spawning a chest (itemcollector) by code. I can only do this by code, because my world is kind of procedural.
To get the right interaction I can also use a scene object for the chest (eg. Chest Scene Object) and display the appropriate infos. But still have the problem (described above) of correctly spawing them by code... :/
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!