Hi.
I'm trying to customize the inventory interaction labels in my Adventure Creator project. Currently, when hovering over a hotspot with an inventory item selected, it shows something like:
Use ITEM on HOTSPOT
What I'd like to do is dynamically show a success percentage based on a variable, like:
Use KEY on DOOR (80% chance)
The percentage would be stored in a variable and used in the ActionList to determine the outcome (success or failure). Is there a way to modify the hover label to include this percentage dynamically depending on the hotspot and item combination?
Also, I’d like to have the label change dynamically depending on the hotspot and item combination. For example:
Open DOOR with KEY
Hide KEY under SOFA
Is there a way to customize the hover label text based on the specific hotspot being hovered and the selected inventory item?
Any guidance on how to approach these?
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
You can modify the "Use" X "on" Y syntax per-item in the Inventory Manager, but it'll be fixed for each Hotspot.
If you want to modify the Hotspot label further, including a chance display, you'd need a custom script that generates the label from scratch.
Something like this, using Unity UI to display it:
Having custom verbs for per-Item per-Hotspot would be a later step. For now, let's focus on the custom label with chance values. How/where are you currently storing such values?
I haven't designed it yet. I'm tinkering to see what the best approach is.
I aim to create a JRPG-style combat system. But rather than selecting attacks from menus and choosing targets separately, players will use inventory items to attack. You'll simply drag a weapon from your inventory onto an enemy. The system will calculate success probability based on both your stats and the enemy's stats. For example, instead of "use sword on enemy," you'll see "swing sword at enemy (50% chance)."
I'm thinking I'll need a combat manager to handle the calculations, and character sheets for players and enemies, which will probably be scriptable objects.
Implementing the code you gave me, I managed to get a label in the scene to display the modified text when an item is over a hotspot. (I do this by placing the CustomHotspotLabel script on the desired hotspot.) But I haven't been able to figure out how to change the actual hover text under the mouse pointer. I can't figure out how to address the Menu/Hotspot/Label text.
The code above is Hotspot-independent. Rather than placing it on a specific Hotspot, you can attach it to your HotspotUI canvas prefab to affect a Text box. This Text box can replace the default one that's linked to the Menu's HotspotLabel element, which is where the text under the mouse appears from.
Oh. Thanks. I'll try that.
But I still need to tell the HotspotUI canvas the % of each interaction. If I put a scritp in each hotspot (on a scene) with the % for each item, how do I send that number to the scrip in the HotspotUI?
The script above stores the active Hotspot in its hotspot variable. You can call its GetComponent function to extract the necessary custom data.