Hi well, I have a problem with some stuff for a long time. I want something like take an object and shows in the inventory and then activate a small animation.
Now I have this:
https://drive.google.com/open?id=1QSWDu_6SoSZTkVxb2hu99MxDySdPmWvJEvery inventory object has the button an animation like you see in the video when you are hover(highlighted).
I want that animation play on the inventory object when you pick up and show the inventory bar.
What I want showing an example it´s:
https://www.youtube.com/watch?v=03Wt5URuKwY (min 2:50 take a cactus and show in the inventory and the animation in the inventory object)
I know I can do something with the custom action script but im a little bit lost with this especially.
Thanks
Comments
-Adds the item to the inventory
-Transition the menu in
-Animate the item
-Transition the menu out
The menu transitions in AC can be done with the Menu: Change state Action, provided that the Menu in question has animated transitions configured.
The Object: Highlight Action can be used to show a given Inventory item's Highlighted texture graphic.
To have such a sequence of Actions run each time an item is picked up, you'd want to look into using ActionList parameters, so that you can create a generic "Add an item and show it" ActionList - and then run it while setting the value of the Item to add/show each time you do so with ActionList: Run.
For something more complex that the simple "highlight on/off" effect, you can manipulate the UI Button/Image component directly if the Menu is rendered with Unity UI.
The following code can be used to access the "UI Button" in an Inventory menu that is associated with a given inventory item:
AC.MenuInventoryBox inventoryBox = AC.PlayerMenus.GetElementWithName ("MyInventoryMenu", "MyInventoryElement") as AC.MenuInventoryBox;
UnityEngine.UI.Button uiButton = inventoryBox.GetUIButtonWithItem (invItemID);
Where "MyInventoryMenu" is the name of your Menu, "MyInventoryElement" is the name of your InventoryBox element (both as set within the Menu Manager), and invItemID is the ID number of the associated inventory item. This can be parameterised in the same way as the steps above within a cutsom Action:
https://adventurecreator.org/tutorials/getting-custom-action-work-parameters
here is the code:
I can't debug your code since it relies on your own menu and UI prefab to work. Try placing in Debug.Log statements within your Run() function to see which variables are assigned vs which aren't.
Also the whole "if (!isRunning) / else" block can be replaced with "return 0f;". Please see the comments in the ActionTemplate.cs script for this function.
The problem i think it´s in the animator.
here is the debug.log console:
https://drive.google.com/open?id=1ldDXHw1JpjJWcgPJarZkF5fcsyCHs2JS
As it's warning you about this, have you assigned an Animator Controller to your Animator component?
Are you sure that's what it is? Try logging the animator's scene:
Debug.Log (uiButton.gameObject.scene.name);
https://drive.google.com/open?id=1PijnvcpivPaIiv-1KDtq5lkAD44UBss-
All the buttons have the same animator controller
https://drive.google.com/open?id=13w3Wq7ADDx6mBfMV2JjWD0zibsVRE7WE
The controller has a trigger called "pick"
https://drive.google.com/open?id=1QM6OSVcRPzs37vvy5GkO67DIEmIRLVMa
The inventory (the gameobject(x) it´s because all the inventory object has a small graphic container)
https://drive.google.com/open?id=114EGTi-1Qg8wcXQ449w1fsAfEhR_xxK9
An the inventory menu
https://drive.google.com/open?id=1Je_eaHJq6gFgAwY--05mp5U5J2vFQpoh
I was confused about the instance because i search if anybody has the same error but only found that but it wasnt.
The problem is when i take more than one object i found it now.
Try assigning the Animator's Controller when the Action runs:
http://pasteall.org/919015/csharp
Animator is not playing an AnimatorController
UnityEngine.Animator:SetTrigger(String)
It was a timing problem i just add anim.gameObject.SetActive(true); after anim.runtimeAnimatorController = runtimeAnimatorController; and works fine!!
Thanks again
NullReferenceException: Object reference not set to an instance of an object
If that's the case, then inventoryBox is being correctly assigned, so the issue lies with assigning uiButton:
UnityEngine.UI.Button uiButton = inventoryBox.GetUIButtonWithItem(invID);
This requires the chosen item (invID) to be in the player's inventory at the time that it's run. You can try debugging further by placing more Debug.Log statements within the MenuInventoryBox script's GetUIButtonWithItem method.
This may even be an issue unique to your project - as it's not a bug I experience at all.
The problem was that this lines of code:
where assigned in the wrong place. It was placed if unity_editor... I sent it out of that if and put it at the and beginning work fine in the editor and build!!!
Thanks, Chris again