(SOLVED) How do I use a global variable number to spawn in objects in a scene referencing another scene

Hi! I’m trying to make a little proto-type game and there is a feature that’s confusing me I’m trying to implement.

So you have one Scene we’ll call it Scene A - you have a player character and they can pick up flowers. In Scene B I want that exact amount of flowers I picked up to be spawned as bigger flowers to use drag and drop for flower arrangements.

What I can’t seem to figure out is how to get the exact number of flowers to spawn.
I either get nothing, infinite, or one.

My thought process is you reference the number in the global variable (I used a global variable to count the flowers so I could use it in multiple scenes) and then spawn the number of flowers as the global variable…because that has the number? I don’t know if that made sense.

Here’s some screenshots.

This is the scene where you pick up flowers

And here are the different ways I tried to get it to work.

I’m at a loss. I have a feeling I’m doing variables wrong…I’m not good at them yet so that might be it. Or its something totally different idk xD

Any help would be nice, just be gentle with me I’m still learning.

Thank you :3

The best way would be to use global variables instead of scene variables in scene A whenever the player collides with a flower. These can then be accessed in scene B.

Also, if flower_pickup_1 and flower_pickup_2 are in flowers group, deleted the flower group after you’ve checked for collision with flower_pickup_1 & flower_pickup_2.

Use a Repeat event, with the global variable as the number of iterations, and the create flower as the action.

1 Like

thank you so much! I tried it but I think I might have misunderstood a step.

All my variables I’m trying to use are Global so…I am doing something wrong XD

Nothing Spawned. I wasn’t sure if I was supposed to do something in “Scene A” too?
I removed the “Delete” entirely and still nothing spawned, I thought that might have been the problem. So I put it back because the number rises too rapidly without it.


Edit: Here’s a link to the project maybe I’m not mentioning something important and don’t know it LOL

So you changed the variables in the following event? Because in your previous screen snip they are scene variables:

1 Like

oh Frik I didn’t realize I did that. I thought it was set as a global.
I changed it, but now it spawns infinitely D:

Here’s the fixed version with global variable.

And I tried both of these ways and both give me infinite instead of the number I picked up.

Thank you for your patience :3

n00b :stuck_out_tongue:

Yes, you’ll need to add a condition to the spawning event so it only happens once - maybe make it a sub event of an event with the “Beginning of scene” condition.

1 Like

I sure am a noob XD

It works now! thank you so much :smiley: I learned a lot.