[SOLVED]How do I get my current items and upgrades to carry over to the next scene?

As the title says, let’s say I my player is equipped with a machine and has an upgrade that lets it have 3 multishots, and when it goes to the next scene it’s carrying the same item and upgrades as it was at the end of the first scene

Hello, Andres_Benovito

Ideally, you should store this information in global variables that can be accessed from any scene:

1 Like

That’s my problem currently, my player and gun are seperate objects and both global objects, I have several types of guns stored inside specific boxes for that specific gun, if my player collides with any of the boxes the gun on the players hand is deleted and replaced with the gun whichever the box the player collided with, another thing is how do I spawn the player on the next level with its current weapon and upgrades with global variables?

I can’t see any problem
You make if player collide with machine gun
Change global variable weapon type to 1

If player collide with shotgun
Change global variable weapon type to 2

(or you could use string variable instead of numbers and go with exact name)

And rest is just setting variable for upgrade type or whatever

Also just make Structure variable Guns
Add child to it call it Shotgun and make it structure
And now add to Shotgun child for upgrade level weapon type or whatever and you are set

I’ll try that out, my power ups I don’t think need to be global variables as I think they wont be a problem atm. but what type of variable should the player be, string, number?

And how would I spawn the player on the next level? because I’ve been searching around and the closest threads I found to my problem is people adding in the event “at the beginning of the scene” then change global variable of the player’s X and Y position.

Just a little example using the global variable:

I made a global group for the weapons:

First Scene

It will change the text of the “Weapon” global variable to the name of the object that the player collided with.

Second Scene

At the beginning of the scene, this event will create an object from within “GROUP_Guns” using the “Weapon” global variable.

Gif picking bazuka:

Gif picking pistol:

Look wanna know my opinion?
You have MANY MANY objects like enemies
That is only situation i would go for object variables

ANYTHING else i always go for global variables
Including player health position any stats upgrades and crap

There is no point in using object variables if you do not have many ob objects

Like for example enemies HP or levels or even some atributtes
They should be per object variable cause you won’t manage that big list on your own (well you can but what for?)

But if it comes down to like idk 5 party members and each with POW STR HP AP EXP and other stats
I see no point in NOT going for global variables

And difference between number and string is string is text which can be for example Weapon1 or 2ndStat

And number variables their values can be ONLY numbers
SO 1 2 3 4 5, and so go on
Now you may ask so if i can use numbers in string variables as values why not use only string?

Well because you can’t use text in number variables BUUUUUT you can for example do
Change number variable add 20 or subtract 20
Or multiply by 5
And you can’t do that with text
You can only set variable to some text

So for example for something that do not change like weapon name i would go for String variables
But for level and exp variables i would go for number variables
So i can do like
Change HP variable to subtract 15
When for example enemy is in collision with bullet or fire or whatever

About spawning player somewhere why you want it to spawn somehwere?
Let it spawn even on moon
NOW you move change position of player to WHATEVER you want at beginning of the scene

@ZeroX4 Hey! I actually figured something out, I got the global variables working and it’s working and the stats of the gun is carrying over to the next scene however there’s a problem with the power up.

I have my player collide with a power up box that will increase its multishot, the player collides with the box and the player infinitely shoots an unlimited amount of multishot, so I put a trigger once but now it will only add 1 multishot and will no longer increase it when it collides with other instances of the same power up box.

What I want it to do is add 1 multishot for every instance of power up box it collides with, I tried changing the global variable event to greater than 0 and it still creates infinite amounts of multishots

We are looking now at your 2nd event
What you have there

The global variable Gun.Multishot = 1

SOOOO in other words you told your game
Perform this action ONLY if Gun.Multishot = 1
And if it is anything ELSE than 1 it won’t work
So you just dig your own grave there
Because now you would need to make another event
With if gun multishot = 2 add 1

What you want to do instead
Change the Number of bullets per shot of gun add 1
Change the Number of bullets per shot of gun SET TO Global.Variable(Gun.Multishot)

And now remove both conditions from 2nd event cause they are not needed
And you will be perfectly fine

Edit part
I forgot about 2 things
1 - Maybe make sub event under 1st event then in sub event in condition add trigger once and to action move change variable action
2 - In separate event make
Gun.Multishot is greater than 10

Change Gun.Multishot SET TO 10

Assuming 10 is your max upgrade for multishot
So if it is 5 you put 5 there instead of 10 or whatever else value
So player can’t upgrade forever

It’s working perfectly now, thank you, the global variables were tricky to learn but this really help my work!

1 Like