so i’ve used some youtube tutorial videos to make an inventory but i’m getting this error despite doing it exactly according to the video,
can someone take a look and tell me what’s the problem?
Hey @primaldragon100
Access none means your variable (in this case your inventory reference) has not been set. When you trying to use this reference to do something (eg. call a function) it will cause this error. You need to double check how your reference is set.
What is your inventory? An Actor you placed in the level (bad) or an Actor Component that’s inside your Controller(good) or Character(okayish)?
it may be an issue with a little diference in the video, in the video it initializes the inventory in the ThirdPlayerCharacter but i made it in the level blueprint like this,
please ignore how it looks like a mess and the stuff after initializing are for making it visible/invisible
and for adding some items from the start of the game.
The visible/invisible stuff works on its own, it became a mess after i made the functions for adding/removing items and trying to see if it would work with adding some items from the start
You want to create a new Actor Component Class and add it to your player character or player controller. This will be your inventory.
The advantage of using a component is, you can re-use it for other things, like chests/containers/shops whatever.
Level blueprint is definitely not the right place for it.
so i initialize my inventory in a new actor, but how do i add this actor in my player character or controller?
Personally I’d use an Actor Component class and add it to the Player State.
Later in your development cycle you’re going to start working on game disconnect scenarios. If your inventory is stored in a level BP, or Character it’ll be instantly wiped without a chance for retrieval on reconnect. Best place is Player state which offers an opportunity on the server side (C++) to do a backup before it wipes its copy of you.
Anyways in the player state class you simply add it in the components tab like you would any other component. Then use the generated reference (variables section) to manage it.
can you use images to show me how i’ll add it in the player state class?