How do I set the scale of an actor to grow/shrink according to how many items are in my inventory?

Hey, I am trying to build a backpack that would grow in size whenever the player collects something into their inventory, as well as it would shrink if the player loses part of their inventory. I currently have a struct set up that splits up larger cones into smaller collectible pieces that fly toward the player after the player does enough damage to the cones.

The issue I am having is getting the backpack to grow accordingly, I was able to make the simple function of rescaling it by pressing the N and M key, but moving that to the inventory has proven itself to be a huge challenge for me.

Something to note is that the only way I found to actually scale the backpack correctly was to do it in the level blueprints as opposed to the corresponding Backpack_BP itself. Any help would be hugely appreciated, please.

Video demo

Gathering Recourses into player’s Inventory/ Resource_Gather_BP

Inventory Struct

Scaling the Backpack/ Level Blueprints

You can get the length of your array and set it as the scale or you can store a float value in your struct as the size increase value that you add to your current scale.

I noticed that the default value for Item Vector is 0,0,0 and I’m not sure how you’re setting it but that’s probably why the scale doesn’t schange.

Oh, I see, Thanks. I added the value for the item vector, as well, as the Item Value and Item Weight to make sure that wasn’t the problem. I went ahead and added the size increase, as that should make what I’m trying to do a bit more simple.

Where would I add that within the blueprints? Part of my trouble, I suppose, is that I’m unsure the best place to call the array to, as well as I’m unsure where to add the blueprints you’re showing.

Whenever you add and remove items from your inventory. So in the Add to Inventory function.

Oh, I see, cool. I created references for the backpack and have the hookups ready in the Add to Inventory line, but wherever I try to connect it it doesn’t seem to cooperate properly.

Apologies, I might need a bit more of your help on how to connect them.

But this way it will increase the size based on how many items you have in inventory not by how much you’ve specified in your struct. And you might be using MAX not incorrectly. MAX node will pick whichever value is greater.

You can convert the length to float and plug it directly into the New Scale 3D. If the array length is 5, for example, the size of your backpack will be set to 5,5,5. If the array length is 0 the scale will also be 0. That’s why I added the max node to prevent 0 scale unless you want that.

Oh! I see, okay. Well, I’ll get rid of the max node and stick with using strictly the inventory size to remain simple for now. When I connect the inventory array to length, would I need to multiply off of the length to then connect it to Set Actor Scale?

Ohhh, oh, oh, I see. Okay, I wanted the different variable types to exist as a means of being able to choose what I’m picking up throughout different levels. Like, in Level 1 the player would need to get items of a certain value, while in level 2, the player would need to get an item of a certain weight.

But, it’s very possible that I set this up wrong from the get-go from that goal, but as far as this goes, yeah, adding a max would make sense to make sure that it grows when collecting something.

After setting it up, it should be working right. but I’m getting reference errors saying that the backpack can’t be found, although I believe I referenced it correctly? It seems like a separate issue at that point, though. Either way, you’ve been a huge help!