Keeping player attributes

Hello! I am making a sort of side scrolling rpg and it has been going good so far! I am wondering however, how can i make sure that the animations are the same upon a scene switch. Currently I have it so that the player collides with the end of the scene and it switches to a new one. This happens. except the player loses all animations and reverts back to the size it was before. Is there a way to keep the animations and such that it lasts through all scenes?

1 Like

1 Like

Im guessing you resized the player in the editor?
Anyways, you would make a global variable(probably a structure or an array), and when you switch scenes, save the info to the variable before swithcing, then in the new scene call that variable to fix the size and animations.

Yes I just resized him lol! Thank you for the suggestion, any clue on how I could go about doing that? I haven’t had to use a global variable yet in Gdevelop.

1 Like

go here
image
then here
image
then


Some info:

and to edit them

Let me know if you need more help, this is a slightly more compact way to use global variables, becuse you technically only need one variable in this setup.

Okay! Thank you so much! I got to the global variables screen and made the first one a structure. That made the little thing under it called a child variable like you had. From that point on I’m a bit confused on what to do next. What type of child variable should I have?

1 Like

Depends on what you are saving, If you are saving size, i would use a number. You can use either the text or nuber for the animation, as you can call the animation number, or the name of the animation, but it depends on preference.

Okay! Last thing! What would that look like in terms of code? Just an example is okay!

1 Like

The variable setup


The changing scene events

and in the new scene

Also, i forgot to mention, this can also be expanded to track stuff like in game currency and health, and whatever.

Thanks! This worked! However it caused me to run into some other issues. The size and such remain the same. However when i switch scenes I am stuck in the run animation I can’t attack, he doesnt flip, etc. Is there a way i can transfer that between scenes other then just copy and pasting it all over?

1 Like

If you are talking about the events that controll the player, you should copy them to an external events sheet, then reference that in all scenes with the player
image
easiest way, is to drag all controls into an event group, then copy that.
image

Okay! I copied them all, how do i reference it in a different scene

The last image i sent shows which button to hit in the top left