This will give you 20 boxes that may (25%) have loot, but no more than 3. If the boxes are already in the level, add them to an array and ForEachLoop through *that *array instead, only setting flags rather than spawning new boxes.
As soon as I posted this question, I thought of something else to accompany it but it might be a bit more work than my first question though… if you feel like you’re up for the challenge, feel free to help me out again!
I’d like to have it as a “spawning volume” that I can place inside the box making it a parent spawner that way I can easily place the boxes around the level.
My follow-up question is:
The loot would be something like 3 apples, 3 bananas and 1 key. How would the parent volume know that out of the 20 boxes (same parent) I’ve placed in the level, only 1 out of the remaining 13 boxes would hold the key the rest would hold 3 apples, 3 bananas and the leftover boxes would be empty? All randomized per playthrough…
If I’m wording it wrong let me know… trying to be as precise as possible.
if it’s a lot of work, you can skip this question… lol
There’d be usually no need to spawn loot until the player opens the box. Once the player does access the contents, the box checks its own *hasLoot *flag - if it’s true, spawn a healthy choice of fruit at the box’s location. If you want to pre-spawn the loot (you may have lots of reasons to do so), you can use the box’s Construction Script instead, showing the hidden items once the box is accessed.
I’m not really sure what you refer to as parent volume - is it the volume that the boxes are located/spawned in/by?
Why does it need to know which box has what? - there might be a reason, just asking
and or *or? *Each box has *either *bananas, apples or a key, right?
all boxes are held in an array, hold the boxes with loot in a separate array; a single box can be in numerous arrays
or give the boxes tags indicating what’s inside
or loop through the boxes array and check if they *haveLoot *and what it is
Consider sharing a bit more about how you envisioned the gameplay mechanic, it might be easier to suggest something more tangible.