[SOLVED] How do make a variable control the number of objects created?

Hi, I’m working on a Sonic fangame and I am currently creating the system to drop rings when hit. I was wondering about how it would be possible to make it so, as long as the user has thirty rings or less, that they lose the amount that matches what they have and not lose any more or any less.

how many ring lose in default, when player has 100?

I don’t have that programmed yet. The idea is that if the player has 30 or more rings, then they only lose 30. And if they have less than 30, they’ll lose an amount of rings equal to what they had. I already have a plan in mind for the variables, I just want to know if there is a way to simply create an amount of dropped rings equal to what the player had without creating tons of similar events with just one variable changed.

I think you want something like this:

isn’t it?

I’m not worried about the variable itself, I’m worried about using the “Create an Object” feature to create a number of dropped rings that matches what the value of the Player’s ring count when they are hit.

that’s the same logic.

I dont know how to scatter the rings nicely. but the amount is correct with this example. and I think this was the question.

I have a system in mind for the scattering by using the Physics 2.0 engine. I recalled that there was a repeat system, but I couldn’t find it. Thanks for the help. Also, my scatter system works fine, but there is one problem, it stacks the rings vertically instead of on the same spot, any suggestion for that? I do not have any programs for the rings colliding with each other.

Also, where is that “Repeat” event?

you can find it on the Wiki. but in the event editor is a great “Plus” icon which says: “choose and add event” somewhere next to the normal “add event” button.

1 Like

That’s pretty neat, thanks!

The only problem is that these things still spawn vertically over each other, rather than in the same position. Do you think that could have something to do with the Physics 2.0 Engine?

sorry, I do not know the physics engine :frowning: . and I’m not sure, use a physic calculation is the best solution for this. but I don’t know. may be expert users can help you with this.

Okay then. Thanks for helping with the Ring system, that was my main issue. I’m sure I can figure out the issue. I’m relatively new to GDevelop, but I’ve always been really good with problem solving as far as programming goes.

1 Like

Probably because they can’t collide?