every single tutorial i watch is about how to spawn random cubes in a big as*s area where it doesn’t even matter where it spawns but in my case i want spawn items inside a small drawer or a cupboard or a box and also each item should be spawned in an appropriate location,
for example, i don’t wanna spawn a car battery inside a drawer or a screwdriver inside cupboard, bcz thats not gonna fit.
also, all of my items inherit from one class called itemparent and that’s where I’ve done the code, i was wondering maybe i can use the parent class to spawn the child actors?
also, the drawers and cupboards are in a blueprint as well, i was wondering maybe i can put a scene component inside the blueprint and get the world transform of that actor to spawn my items instead of going through the instances one by one.
how do i get the location of each instances tho? there’s like 6 drawers in my game which are just instances of a single class, just getting the location isnt gonna work cause 2 items might spawn in a signle drawer, so i need to know which drawer has already spawned something.
i need to add its not just a single item there’s 4 item that should be spawned inside 6 drawers, so 2 drawers should always be empty and the rest should constain different item everytime the game is restarted.
Probably you can add sockets to your drawer mesh inside UE editor. Each socket could play a role of a spawn coordinates. Then just get random socket from current instance of a drawer and attach your item.
Additionally you should save info about what sockets are already taken to prevent spawning multiple items in same location.
im not really worried about where it spawns inside the drawer cuz the mesh is simulating physics so it will adjust itself to fit. my problem here is that the random integer in range is returning 3 random numbers instead of one.
is that normal cuz i thought that function is supposed to return something random between max and min.
Make an array and save the spawned item in. You can use add unique. Before spawn just ask in an IF if already spawned.
When you make SpawnActor you have a return value, save that in the array