0
Answered

Inventory Module - Consume error

Dyang 3 months ago in Inventory updated by Marti (Lead Developer) 3 months ago 2

I just got Inventory module and am trying to configure my own menu. I tried the example scene of course, everything works good. But when I try to implement on my own scene, consuming items are not working. I get the error below. 

I am able to use the potion prefab and I can pick them up. But when I click on it in the menu, the error shows up and the potion is not consumed. Trying the same method in the example scene (placing the prefab to pick up instead of purchasing from merchant), it works as expected. 

I even started a fresh project in case I messed something up. Created an 'Apple' item that can be picked up and consumed. Same problem occurs. I even went back into the example scene and recreated my Apple in there with same settings...and it works! But not in my own scenes however :(

----------------

Am I doing something obviously wrong? Needless to say, I am very confused. What is the example scene doing that I'm not doing?


Any help would be greatly appreciated!

Unity version:
2019.4.0fi1
Game Creator version:
1.1.9 - ALPHA

Answer

+1
Answer

@Marti, I posted this over in the discord also, but might as well leave it here too.


I figured out my error. Turns out you need an actual Player Character component, otherwise items can't be consumed and you get the error I was getting. I'm not using a controllable character in the traditional sense in my game, so I had created a Character component instead (controlled by clicking). Instead I should have created a Player Character with "Is Controllable" turned off. Not sure why a Player is specifically required, but whatever. This wasn't noted anywhere in the documentation or tutorials, so I figure might as well bring it up here. Cheers!

+1
Answer

@Marti, I posted this over in the discord also, but might as well leave it here too.


I figured out my error. Turns out you need an actual Player Character component, otherwise items can't be consumed and you get the error I was getting. I'm not using a controllable character in the traditional sense in my game, so I had created a Character component instead (controlled by clicking). Instead I should have created a Player Character with "Is Controllable" turned off. Not sure why a Player is specifically required, but whatever. This wasn't noted anywhere in the documentation or tutorials, so I figure might as well bring it up here. Cheers!

Answered

Yeah, the Inventory requires a Player Character, because the "Invoker" used when consuming items is the Player. I assumes that you'll have one.

Despite this, if you have a custom character controller, there's a work around. You can add a "HookPlayer" component to the game object you're treating as the Player and it will use that as a player reference.


No need to create a dummy player character. Cheers!