Hello there!
I want to create a custom inventory bar and inventory interaction, where the player, a chicken, can lay the inventory as eggs.
You click on an inventory (it is now highlighted and selected), and then when an inventory is selected you click the 'Lay as egg' button on the left.
Now the chicken will lay an egg. Usually the egg will crack and the item appears. There will be a few other events in some situations, where laying a specific object, or a specific object in a specific place, will trigger special events and animations.
Now I'm fairly new to Adventure Creator and Unity so I do not have a clue on how to create this, and how to implement any of the steps outlined below.
If someone could give me a layout on what the most efficient way is to create this, I'd greatly appreciate it.
Knowing how to create this will also help me how to plan and set up the animations and graphics in advance and save me tons of time.
Are there any resources that I can read and learn more on the subject?
Here are the different steps to integrate for this interactive inventory bar in detail:
1) an inventory item cannot be used by dragging it's icon into the environment, or clicking it and then clicking on the environment.
2) however an inventory item can be clicked and dragged unto another inventory item inside the inventory bar, to combine two inventory items, if the combination is possible. Alternatively, you can click an inventory item, and then click on another inventory item to combine them if possible.
3) An inventory item can be selected by clicking on it. When selected, the graphic of the item icon changes, or a VFX is added to the graphic (brighter color, and outline), so that the icon is now highlighted, and clearly selected.
4) The selected inventory item gets unselected whenever you click anywhere in the real world outside of the inventory bar, or when you select another inventory item, or click on an empty space in the inventory bar.
5) If an inventory item is selected in this way, and you click on "Lay as egg", the chicken will lay an egg, which contains the selected item. This will remove the item from inventory, add it as an object in the real world, while triggering the following animations:
6) In some cases, after these animations are played, and the item is removed from the inventory and added as an object in the scene, there might be additional events: the object interacts with other objects, the object moves, more animations play, etc.
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
A fair bit to unpack here - and some of the latter is a little more advanced than standard inventory usage. If you're just getting started with AC, I'd recommend taking a look at this tutorial, as well as the Manual's "Inventory interactions" chapter to get an overview of how Inventory items can be used on other objects.
Inventory items are used in the scene by creating an "Inventory interaction" for them in a Hotspot's Inspector. To prevent usage in the scene directly, you can just avoid defining any Interactions.
Inventory items can be combined by defining "Combine" interactions at the bottom of their properies panels. For each interaction, you must assign an ActionList asset that runs, as well as the associated item it will run for.
By default, a combine interaction is one-way - using Item A on Item B will run the Combine interaction on Item B. You can have the reverse work automatically, though, by checking Combine interactions work in reverse? in the Settings Manager.
If an Inventory item has an "Active graphic" assigned, it can be used when the item is selected - both as the cursor, and as it appears in the Menu.
Check Left-click deselects active Item? in the Settings Manager's "Inventory settings" panel for this behaviour.
I'd recommend looking into animations later, and just getting the behaviour of the item appearing in the scene working first.
For the "Lay as egg" button - there's a couple of ways you could go about it.
To do this, define a pair of Categories in the Inventory Manager - Normal and Lay - and then place your regular items in the "Normal" category, and a new "Lay as egg" item in the "Lay" category.
Then, in your regular InventoryBox menu element, check Limit by category? to have it only show items in "Normal" category.
Finally, replace your "Lay as egg" button in your Menu with a new InventoryBox element that similarly limts its display to items in the "Lay" category.
To spawn an item in the scene, you can use the Object: Add or remove Action.
To play an animation where different elements need to sync up, you can use Unity's Timeline feature and the Engine: Control Timeline Action. When dealing with dynamic objects, i.e. those that are spawned into the scene at runtime, you'll need to use the Action to remap the Timeline's bindings - a tutorial on this can be found here.
However, the link between Inventory items in a Menu, and their representation in the scene as proper GameObjects will be given attention as part of the next AC update, v1.78. This update will make it much easier to handle the spawning of Inventory items in the scene, and use further Actions to affect them afterwards. You're welcome to PM me your invoice # if you'd like to be involved in testing.
An object spawned in the scene with Object: Add or remove can have a Hotspot attached to make it interactive - but again, the next update will make this workflow easier.
Hello @ChrisIceBox,
Thank you very much for all the detailed descriptions on how to set it up!
I was able to set up the 'Lay egg' button as both a traditional button and as an inventory item.

Creating it as a button will be an actual scripting nightmare later on, as you mentioned, because in the final game you will be able to lay every single object as an egg.
So I would like to use your inventory "button" solution, with the combine action.
I forgot to mention one aspect: When clicking on the lay egg "button", without any inventory item selected, the Chicken will lay a simple egg, containing no object. I hope this will still be possible using this solution?
So far I have 3 issues while implementing the inventory button solution:

1) Even though I have no events set up for using any item in scene, it displays "Use [selected item] on [object name]" when hovering over objects in the scene. I don't want that, but I would like it to display when hovering over other inventory items.
2) The Egg Lay button acts as an inventory: When I activate the inventory box setting 'Prevent Selection', I am still able to select the 'Lay Egg' inventory item and it acts as an inventory ('Prevent interaction' doesn't let me use other items on it which is also not what I want). How can I turn the behavior and visuals to that of a button (with a separate Hover and click visual)?

3) Since it acts as inventory, it entails 2 more issues:
That's awesome!
I will wait then before implementing the object appearance and animations until the new release. Is there a time frame I could expect for the new release? Days? Weeks? Months?
Yes, I would love to do beta-testing on it! Will send you the invoice.
Yes - you can assign a "Standard Use" interaction to the "Lay egg" Inventory item, which will run when clicked without any other item selected.
If the Interaction system is disabled, Hotspots will not be responsive. Through scripting, you could try auto-disabling the Interaction system whenever an Inventory item is selected. This script should do it:
The 'Prevent selection' behaviour may be a bug - I'll look into it, thanks for raising the issue.
Given the visuals and other behaviour you're looking for though, it sounds like it'd be best to go for a hybrid approach - where you use a Button menu element after all, but store the Interactions inside a "Lay egg" Inventory item that's never shown. Through script, you can have a Button click run the correct Interaction from the "Lay egg" item:
Thank you for the script, it works. I realized I can also tick the option "Auto-disable items with no interactions for selected item?" instead. Right now it displays "Use [selected item] on" when hovering on the scene, and "Use [selected item] on [inventory item]" when hovering over other inventory items.
How can I have the text display disappear when not hovering over an interactive inventory item?
Thank you for the code. How can I run the mono behavior from the action list?
I tried to run it this way but it did not work:

I set it to "Runtime only", inserted the monoscript asset object "Lay Object Egg.cs" and added the Monoscript.name string "Lay Object Egg" (I also tried "Lay Object Egg.cs" and the behavior name "LayObjectEgg" instead).
I made sure all the script names correspond ("Inventory", "LayEggButton", "LayEgg").
Console didn't display anything.
It didn't work.
Disabling the Interaction system - which the script does - should handle that.
The script uses AC's event system to run itself automatically - you don't need to trigger it through Actions, just keep it placed in the scene.
Events are a way of automating blocks of code when AC performs common tasks - in this case, whenever the Menu is clicked on. A tutorial on their usage can be found here.
But no, it still displays the text.
Thank you, it works perfectly!
Odd, it does on my end.
As the Inventory menu only appears when the mouse is over it, however, you could try a custom script to lock the Hotspot menu whenever the Inventory menu is off, and an Item is selected:
Adding the additional script doesn't resolve it either.
Just to avoid any confusion, I am talking about the text "Use [item] on" when selecting the inventory.
I would like the text to only display when hovering over another inventory item:

My inventory settings are the following:

And I might add that when adding the first auto disabling script, this one:
then it does not deselect the inventory item when clicking anywhere empty anymore. Which is another reason why I prefer to use the setting "Auto-disable hot spots with no interactions for selected item?" instead.
What are your Cursor Manager's "Inventory cursor" panel settings? Try checking the Only show label when over Hotspots and Inventory? option.
The script can be updated with that functionality. Try this:
Yes that was it!
Yes, that works, too, just had to add in the script 'AC.' in front of for example 'Kickstarter'.
Thank you for your help, solutions and ressources.