To start, I’m not the best at blueprints but I know my fair share. But, I was interested in spawning objects between 2 spherical collision boxes. Reason for this is I am creating a space game with 1 main planet, and I don’t want space ships to be spawning too close or inside the planet mesh, as I’d like a specific amount of ships to be in the scene at all times (player collects 1, a new one spawns). I also don’t want to use any box extents because my maps bounds are spherical as well.
So after stirring up some blueprint stew, I created this: SpawnItems (Function)
I know the cast to inside removal area is not connected, just wanted something to work for right now. Heres what the - Inside Area Removal - looks like so far: Inside Area Removal (Event Graph)
So after I created those I just did a simple switch on int and then cast to Spawnitems Function, which works perfectly if I was not trying to remove the items inside the other sphere collision.
[SPOILER]Here is what it looks like:
The point of this image is to focus in on the one cube that is inside the red ring (Sphere1, sphere collision). Inside those red rings is where I don’t want the cubes/objects to spawn.
Note: There is 6 cubes in this preview (you can only see 3), for test purposes. Also, please excuse the SpawnArray function, I was testing with arrays. In this working preview, everything was disconnected from that function in order to work.
Please if you have any ideas, send them my way! Thank you!
Well, I knew I was forgetting something, but I wanted to spawn them outside of let’s say 500 meters away from the planet as well, hence my use of another spherical collision. My original idea was when each spaceship was created I’d add it to an array. Then, once inside the array it would check if it was in the bounds of Sphere1 (Inner collision) and if so, remove the mesh but it would only allow me to remove it from the array. Which, I’m not completely sure, but if I remove it from the array, would it remove the physical mesh in-game?
So the questions to answer would be:
If I remove the static mesh from the array would it also remove the mesh in game?
How would I go about setting up a set radius for the spaceships not to spawn?
What type of nodes would I be looking at? EX: (Array, loop, etc…)
P.S: Yes I already have the random point and spawn mechanic working. Just need the removal/recalculation of a mesh.
Sweet! I’ll get to testing it soon but I’m almost certain it will work anyway since the code looks good. I didn’t even think about spawning it from the centre of the planet lol. And yes it’ll work perfectly for my game since there’s only one planet. Thank you again!
Alright so I got to test it out, I copied your nodes down to every variable name, and yet objects/spaceship won’t spawn. I feel like this is just a dumb mistake somewhere inside some variable, but every time I check each variable, function, node, etc I find that all the math and nodes are correct, they just won’t spawn. My construction script is just dragging out the exec to spawn items function, and my event beginPlay has its exec dragged to spawnItems too. Here’s what the rest of my BP looks like:
Note: You can also see my variables and local variables on the left side. And sorry about everything being clumped up, I wanted to get everything in the picture.
Also, inside of the spawnItems function, I tried replacing the random float in range to Random point in bounding box (Sphere1’s collision) and that didn’t work either. But again, they are basically the same thing.