Pickup formations in Defold

What’s the best way of dealing with spawning many RANDOM pickup formations?

Ideally I’d be able to design the way the pickups are laid out visually. I was initially thinking of using a factory, but they allow only one game object to be spawned at a time.

Maybe the pickups have to be laid out by code, rather than positioned in the editor?

1 Like

Perhaps you can use collections and collection factories?

2 Likes

That’s actually what I decided to try first! I’ve never used collection factories before, but they seem to work great.

I would have done it another way with coding indeed, and it simply means doing like this.

local arrangements = {
vmath.vector3(1,1,0),
vmath.vector3(-1,-1,0),
vmath.vector3(1,-1,0),
vmath.vector3(-1,1,0),
vmath.vector3(0),

}

local distance = 16

local function spawn(base_position)
for i = 0, #arrangements do
local pos = arrangements[i] * distance + base_position
factory.create("/game#coinsfactory, pos)
end 
end 

This will simply create five coins in a square shape around the player, and the best part is that this is highly configurable, so. you can just decide on the shapes you want to spawn the coins in.
(writing code is a difficult job on mobile :sweat: )

3 Likes

Thanks, yeah this could well be an option. Probably less taxing performance-wise too, right?

Exactly.(or maybe I think so, not quite confirm on the memory factor though)

1 Like

Spawning each coin with a factory using a position from a table is the way to go. But you can still use some external tool to create the arrangement. A spreadsheet document or a tool within the game.

1 Like