Problem with variable for each same blueprint instance

Hi everyone, I have 3 static mesh blueprint in my world, it’s 2 bag of 0$ and a heap of money (5000$), when I get the money in a bag this bag contain 5000$, when I get another bag, it don’t have 0$ but 5000$.

Do you have any idea?

http://puu.sh/twyJs/c73e54cf3e.jpg

http://puu.sh/twyKX/cf647f4777.png

So for more precision:
I get a bag, the print string told me 0$
I get the heap of money, I drop it and I pick it, print told me 5000$
I drop it, get a bag that normaly have 0$, 0$ was print, I drop it and pick it, and I’ve 5000$ instead of 0$

So you spawn two Bags of the same class Duffle_Bag_Blueprint and then a Character/Pawn can check how much money a bag has and populate it with money?

If so, then when you want to sort out the correct Duffle_Bag_Blueprint Instance (looks like you use some type of trace) and call the Set Money Amount to that specific Duffle_Bag_Blueprint Instance.

Now it looks likes you are setting the Money Amount on Spawn for every instance of the bag and not based on Character Interaction.

I resolve the problem, but is not a good way to do that,
I replace the destroy actor (Screen 2) by a Set Actor Hidden In Game, but if I’ve a lot of bag this gonna be laggy, a way to fix that?

Ok, I don’t really understand what you want to do with the bags.
Do you want the character to be able pick up the bags and loot them for money and then destroy the bag?

I want create a Payday like, so I need to get heap of money into bag, and carry it to a specific area

Do you have the variable set to editable in other instances of the blueprint?

For one, it doesn’t look like your != boolean has anything set to compare against. Perhaps you were looking for something more along the lines of “IsValid”? What’s the exact purpose of that node?

Oh yeah, I forgot the Editable checkbox, thanks!

Another question, how to set up my bag variable without spawn a bag actor when I pick a heap of money?

If I’m understanding your sentence correctly, it seems you want to set the variable without spawning the actor.

You can create an instance of an object without spawning it by using a [Construct Object] node. From there, it will give you the instance reference and you can store it in a variable that stores an actor reference. However, I do not think that this is suited for your purposes.

I suggest creating a [Struct] in your [Content Browser] and adding two variables:

  • {Actor Class} (The purple one, not the blue one): “MoneyBagActorClass”
  • {Float}: “MoneyAmount”

Name these two variables as you see fit. From there, add your new [Struct] to your character by creating a variable and changing the variable’s type to the new [Struct] you just made. Do the same for your inventory, adding a new variable and setting it to be your [Struct].

In your inventory blueprint, or whichever blueprint you’ve been using for picking up the bag, create a function that will erase the variables in the [Struct] variable you made.

Now you can simply use [Spawn Actor from Class] and set the actor’s [Struct] variable to exactly what was in your inventory, without having to set the details each time.

When you pick up the bag, just do the reverse; get the actor’s [Struct] variable and store it in your inventory’s [Struct] variable. Then, simply [Destroy Actor].

If you wish to set the individual variables in your [Struct] variable, use [Make struct] and [Break Struct] nodes in your blueprint.

This keeps the bag’s data consistent between the map and your inventory without having to store the actor’s reference ID.

I see!

Then I think @Zakku Arashi in the comments here have a good answer where he explain a good method to achieve what you are looking for.

Thanks!!!
I add a new struct why bp class amount money, and a boolean to know if bag if carried or not.

Thanks my friend for this reply you’re my god