I am doing the Unity Adventure Game tutorial and making small improvements to learn Adventure Creator.
When the player picks up the glasses, I don't have her equipping the inventory item automatically. Instead, the player must select this from the inventory and then click on the themselves (Player character) in order for the ActionList to begin in which she equips the glasses.
What are some best practices for this, should I use a Hotspot / Trigger etc, and how to handle the Text that is displayed in this situation when hovering the mouse?
For example, if the glasses are selected from the inventory and the the mouse is hovering over the player, instead of displaying "Use Glasses On Player" could some other text be used such as "Equip Glasses"?
Thank you
Comments
Another thing to keep in mind is that your Player's Hotspot should have its Interaction source field set to Asset File, so that it runs ActionList assets when interacted with. This way, you can run the same Actions regardless of which scene you're in.
You can define a "Use" interaction for an item in the Inventory Manager, which will run when left-clicked. That will override the default behaviour of it becoming selected, but you can select it manually by ending your ActionList with the Inventory: Select Action.
However, you will still need to turn off the Hotspot when the item is no longer selected, so instead it's probably better to have a looping ActionList that runs in the background and enables/disables the Hotspot as necessary.
The Inventory: Check selected Action can be used to determine if a given item is currently selected. Following this up with two Hotspot: Enable or disable Actions that turn the player's Hotspot on/off accordingly, and then looping back onto the first Action will cause it to continually check. You must also, however, insert an Engine: Wait Action before looping to prevent it looping instantly (causing a crash). Here's an example using the 3D Demo's assets:
https://imgur.com/a/YqvW4
Put these Actions into an ActionList asset, and set the asset's When running field to Run In Background so that it doesn't interfere with gameplay. You'll have to run it from your scene's "On start" Cutscene using the ActionList: Run Action.
Of course, it's also possible (and may be easier, depending on experience) to just do it through scripting. AC's custom events system (see Section 12.3 of the Manual) allows you to easily run custom code when AC performs common tasks.
It should be possible to enable/disable the Hotspot using OnInventorySelect and OnInventoryDeselect events to run the Hotspot's TurnOn and TurnOff methods.
It is, but this time only through coding. This time, you'd want to use the OnHotspotInteract event to change the item's syntax when hovering over the player's Hotspot. To get an API reference to any Manager field, just right-click on its label. Then again, if the previous answer solves the issue this may be unnecessary.
If you'd like help with scripting, just say.
private Hotspot myHotspot;
void Start () {
myHotspot = GetComponent();
EventManager.OnInventorySelect += InventoryItemSelected;
EventManager.OnInventoryDeselect += InventoryItemDeselected;
}
private void InventoryItemSelected(InvItem item) {
myHotspot.TurnOn();
}
private void InventoryItemDeselected(InvItem item) {
myHotspot.TurnOff();
}
}
You can also assign a Higlight component to the Hotspot that can trigger events when highlighted / unhighlighted. You can uncheck Auto-brighten materials? on the Highlight component to prevent any automatic visual effect.