Random Item Spawning

Hey!

I’m currently working on a small project involving a 2D game. One of the mechanics of the game is collectable coins will spawn in random locations around the map (within a large volume box). X number of coins will spawn based on a for loop, and random coordinates will be provided for the spawn location of each individual coin. Currently, that’s all working.

The issue I’ve run into is that coins have the ability to spawn inside of terrain currently, where they are not reachable by the player, and I’ve been wondering how to disable that. I’ve also been wondering how to get the coins to spawn within X distance of a terrain tile (if that’s possible) so that they’re still reachable by the player and not in the middle of the air where the player cannot get to.

Any help with this would be greatly appreciate!

Also, here’s the blueprint for the random coin spawning mechanic: http://puu.sh/mXVXF/376bf7de23.jpg

Have you tried changing the collision handling override?

Use not only one big volume, place small ones to fit terrain/spawnloc.
You can put them in an array and randomnize output.
:slight_smile:

I’ve tried setting the spawn collision to adjust the spawn location, but to no avail.

I’ve considered setting up numerous smaller volumes around the level, rather than one large overarching volume, and it’s certainly doable however due to the level layout, this could become rather a rather troublesome alternative. Would there be any way to set up collision detection in the blueprints and have it alter the spawning coordinates if a collision with terrain is detected?

Spawn actor and align above terrain - World Creation - Unreal Engine Forums ?
:slight_smile:

i haven’t experience working in 2D, but in 3d game i have a “Random Spawn”. That send a “Sphere trace” from a random point to his vertically, if hit the terrain spawn in the location i use the sphere radius for detect if there another spawned object nearby.