How to spawn random item at random location?

It’s this then:

No need to fiddle with removal.


You need to do it outside of the Cabinet class. Think of the above script as a spawner. It can be in the Game Mode, it can be in the Player or LB or, ideally, a separate actor. This way you can easily extend it with extra functionality later on.

The idea behind it:

  • we grab all Cabinet actors and put them in an array and Shuffle - randomising their order
  • we then step through the item classes that need spawning, and Get a cabinet for each
  • Spawn the item & place it at that Cabinet’s transform

This way you’ll end up with 1 item of each type in some of the Cabinets, at random. The above assumes there are more cabinets than items. But you say it’s the case here so no need to check for bounds or anything else.

Finally!!! fking thank u bro. i mark ur reply as answer