ClockworkOcean:
Hi - so, no. Removing it from the array would not remove it from the game, you’d need to use DestroyActor and then remove it from the array.
Rather than spawning and then removing the ones inside the planet, why not spawn them at a minimum distance from the planet centre. That way they will never be in the planet.
Imagine a line extending from the centre of the planet. It can take on any angle, but it’s length must be at least the radius of the planet.
That way you get no ships in the planet, but you still might get ship overlapping, so you have to check before you spawn ‘is there already another ship here?’.
Strangely enough, I have already written some code like this for my game, will paste it here:
So, it’s spawning islands, but you can just change that to spaceships
Notice, I’m check if the location is already used, that goes like this:
That’s the whole thing! Something to bear in mind though, this is assuming it’s spawning around the origin, you’ll have to tweak it if you want it to work at another point in space.
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!