Help with spawning objects at random locations

Hello all, i’m trying to spawn an item at the entrance of one of the buildings in my level at random. I have a component in my building blueprint that acts as the origin point of the item, but i can’t access the location of that component from the level blueprint. What should i do?

  • what type is Shops array?
  • what happens when you search for Item Origin from the blue pin - it does not find it?

Also, you’ll eventually need this me thinks:

The array type is actor. It can’t find the Item Origin which comes from the blueprint of these buildings which i placed in the map and added to this array. But one way i could make it work was by making a Building parent class and casting to it to find that Item Origin, it works but i don’t know if it’s the most efficient way.

Thanks for the advice though!

Either set the type to the same type as your shop or Cast To Shop first.

It’s fine for something like this.

You could avoid casting if you made the Shops array Shop_Parent type. And Item Origin was an inherited component present on the parent.

If this is parent <-> child relationship:

And the array is of Parent type, it can now store any child too. That’s providing this array is for Shops only, ofc. It is, judging by its name so this should be OK.

That’s good to know, thanks for the detailed explanation!

1 Like