One of my items has a four-frame graphic assigned to "cursor (optional)", and under "additional settings" I have "always animate?" checked. The main graphic is empty, but I use this script to animate the icon in the inventory as well. Here's the relevant snippet:
void Update()
{
// This is to animate the lantern icon in the inventory
if (AC.KickStarter.runtimeInventory.IsCarryingItem(1))
{
IconAnimated = AC.KickStarter.runtimeInventory.GetItem(1).cursorIcon.GetAnimatedTexture(true);
if (IconMain != IconAnimated)
{
AC.KickStarter.runtimeInventory.GetItem(1).tex = IconAnimated;
IconMain = IconAnimated;
}
}
}
Now I've just assigned a graphic to "active graphic" as well, hoping that when I hover the selected item over a hotspot or an inventory item with an interaction, the active graphic will be displayed. If the active graphic could be animated, that would be cool, but I'm not too fussed - the main issue I'm having here is that it never switches from "cursor (optional)" to "active graphic" at all. Is this intended?
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
If a dedicated cursor graphic is assigned, then that will be shown at all times.
If this cursor graphic is animated, however, you can have it play the animation as part of the "active" FX - while only playing the first frame otherwise. This can be done by unchecking Always animate? in its animation properties.
If you wanted to have two animations - i.e. one when normal, another when "active", you'd need to replace the texture of cursorIcon itself.
Thanks! Yeah, I wanted to either have two animations, or only one animation but the other way around (i.e. animated when inactive, not animated when active). I think I understand how replacing the texture works, but I'm having a hard time figuring out how to check whether the state is active or not so I can replace the texture at the appropriate moment.
Something that I've noticed too is that after I run
AC.KickStarter.runtimeInventory.GetItem(1).cursorIcon.ReplaceTexture (myNewTexture);
, my script above stops updating the main graphic with the current animated frame pulled from "cursor (optional)", and instead it pulls the entire "cursor (optional)" texture. So even if I could check for the active state, the texture replacement part wouldn't work correctly.Just so it's easier to understand what I'm trying to achieve: I have a flask item filled with fireflies. I'm trying to get the fireflies to bounce around the flask at all times (both when the item is in the inventory and when it's selected as a cursor). I also want to highlight the flask when it is placed over a hotspot or item it can be combined with.
If you want to check if a Hotspot is currently active:
You can also read this function's return value to check properties of this Hotspot, if necessary.
Should the item in the Inventory remain animated even when the cursor is changed to the "active" mode?
If so, you're probably better off copying the icon completely so that it uses a separate icon that's unaffected by further changes.
Something like:
I think I got closer, but still not quite there:
There are two issues here:
(1) KickStarter.playerInteraction.GetActiveHotspot() only returns interactions with hotspots, not combine interactions between items, so this will return null when you hover one item over the other, even if they can be combined.
(2) AC.KickStarter.runtimeInventory.GetItem(1).cursorIcon.ReplaceTexture(lanternActiveTexture); kind of works - the texture will change correctly in the inventory manager! But this is not actually reflected in the game. The regular texture is displayed.
Ok, an alternate solution that ALMOST works! This is what I did:
(1) Create a dummy item, add the texture with multiple frames to its "cursor (optional)" field, and configure all the animation settings you want. In this case, my dummy item's ID is 19, and the real item is 1.
(2) For item 1 (the real item to be used), add a main graphic and active graphic texture. They will be replaced at runtime, but it's important that they are assigned.
(3) Run the game. It works as intended!
The one problem I'm running into is that when I exit Play Mode, the manager's main graphic and active graphic will revert back to unassigned. You'd think this wouldn't be a problem because the script above assigns them at runtime, but for some reason, AC will only use the active graphic if there was already one assigned there before you click Play.
If anyone's interested, I've managed to make this work with this adaptation:
Basically, by updating the item's tex in the inventory manager, the main graphic will animate in all inventories and containers. And I solved the ActiveTex issue I described above by updating only the selected instance's active texture. This means that the active texture in the manager won't be changed to none upon exiting Play Mode, which was what was breaking my previous solution.