I am building a quest game where collected items transform in inventory by creating blueprints for each item that is to be picked up. My goal is that when 10 empty bottles are collected, a full bottle is generated in the inventory - and that all works. But I want the 10 empty bottles counter to reset to 0 when the full bottle is generated. Why is the Set function for collected bottles empty variable not resetting that variable to zero?
It’s not the same variable ![]()
Also, you need to execute destroy actor(self) last, because nothing executes after you destroy the actor. And you need to connect return value from spawn full bottle mesh to set material target. Though the full bottle you spawn should already have a “full bottle” material anyway.
The variable (integer) is Collected Bottles Empty, which is what I want to reset to zero.
Could you explain?
The variable Collected bottles empty is a variable in the third person character. That is the variable I am referencing
read again ![]()
^This.
Drag off the as ThirdPersonCharacter cast, and set their bottle var. As it is, the set node is setting int var on the bottle.
Probably better to do this with an interface, and an inventory component on character either way.Doing it like this on the item itself will mean lots of duplicated code as you make new item types. Using an interface with a function called AddItem or something. each new item would only need to call that interface function on overlap, and let player bp or an inventory component decide whether to add more or create a new full item or whatever.
Try something like this..
First, add an AddItem function to player like this:
Then when item overlaps something, make sure it’s player by casting to them, and call the additem function:
I just used a string for item name (it’s a public var on pickup class, which is feeding the AddItem function call) for a rough draft, but you could use name/enum/whatever. Just need to tweak the add, remove, and == nodes to match. In this case I just appended "bag of " to front of item name string to make the version with 10 items in it, but you vould use select or something to make specific things like full bottle or whatevs. To spawn an actual item actor, make another function in player (or game mode or something) with the new item name as an input, and call it before returning true or false to pickup actor.
Could also ditch the branches off length < inventory size if you don’t want to limit how many items a player can carry.







