In this video, I go over how to change scenes in your game by having your player walk towards certain areas in your map. / arkevegames itch - arkeve.itch.io/
For anyone wondering about the error "The identifier "Global" isn't declared in the current scope.": Try changing your global.gd to uppercase Global.gd - it needs to be uppercase. Also don't forget to put the Global.gd to autoload as Arkeve mentions in the video.
Thanks for the help! can you think of any reason why the portal works on the initial scene but i cannot return once in the second scene? edit I made it work. i just turned the layers and masks on and off until it worked. cant say i solved it.
This is probably too late to get a response but when I try to use Global.player_initial_map_position = player_spawn_location in my Portal script for example I get an error saying "The identifier "Global" isn't declared in the current scope." Any help would be appreciated, thanks!
How to do handle having the player enter from 2 sides of a scene? For example if the player enters from the left of the mines or the right, would you just have 2 player nodes in the scene and hide depending on which side you've entered from?
Trying to implement this into my game ( also thank you for being the only person to post a video on this!! ) but was wondering what is your global script attached to? I have a base world node and was wondering if i should put it on that or how to use the global script? Thanks for any help you can offer!!
You don't have to attach the global script to any node. You would have to make it an Autoload script though. Go to Project Settings -> Autoload tab and select the Global.gd script and click add. By making it an autoload script, the script automatically loads onto your scene tree and you should be able to access the script's variable in other scripts through: `Global.variable_name`
I'm wondering if it would work out to have invisible nodes in each scene to pinpoint the spawn locations. Then you'd have to reference that node by... a string, or something, I guess.
I wonder in your game if you decided to add the cave part before you get to the cave, as a few intro tiles, to let you know you're entering into a new scene? I've seen that a lot since the 80s on various games, in NES. It builds anticipation of the next area.
I know this goes kind of out of the scope of this tutorial, but I would personally prefer having some singleton managing the scene changes, and having it create a signal that can then be called by any node that wants a scene change, one of which could be the portal.
"The identifier "Global" isn't declared in the current scope.' This shows in both Player and Portal script. Setting the Global script to autoload in project settings, did nothing.
I've preload the script and = it to var Global. The previous error is gone but another shows ! "Invalid get index 'player_initial_map_position' {on base: 'GDScript'}"
Change to "var Global = load("res://Scene/Global.gd").new();" as suggested on godotengine forums. When i put it in player script the game crashes on entering the portal.If added to both player and portal script, change scene works but teleports me in default position set in global script. I give up.
Hey, you shouldnt have to preload the global script. After setting it as an autoload script you should be able to access it in any script be "Global.variablename". It might have glitched when you first tried, try restarting the engine and accessing again. Hope it works!
Again if i don't make a variable Global in some way in Door and Player script Godot gives me error: "The identifier "Global" isn't declared in the current scope.' Player and or Door script seems to not see Global script even if autoloaded. Restarting Godot did nothing. Thanks for quick answer, maybe i find some other solution.
Holy shit, it worked! I just repeat every step once more from the start!! I'm so sorry for pester you like this. But you are literally the only person on youtube who explain how to change scene with custom spawn points. Works like a charm!!
Hey, thanks for all the help. I noticed you mentioned that if the game is top down, you have to worry about 4 directions. My game is top down. I tried implementing Vector2 in the facing directions but that didn't work. Can you help me out?
It really depends on how you implement movement in your game. I assume you change the player's direction depending on their velocity. But if you want to start the player in a certain direction, you can play the corresponding animation (idle direction animation) depending on a Vector2 value. Vector2(1, 0) -> facing right Vector2(-1, 0) -> facing left Vector2(0, 1) -> facing down iirc Vector2(0,-1) -> facing up. In your player ready function, you load this Vector2 value from the Global.gd script and play the corresponding idle animation.
Amazing tutorial!! question: Can you have multiple portals? as in multiple exits that take you to different maps? I think it's possible to just add more portals but I haven't tested.
By having exportable variables you can indicate which scene and part of the map you want to go to. You should only load the string from the path of the specific scene
hmmm what if id want to have a the transition fluent/flawless/smooth instead of imidiate jump to different scenery. The ideal would be to have the camera and background follow the player in seamless long transition or even a huge, long map. But i have no idea how to do it. When working in Godot i can only see the rectangle that is limiting what player will see on the screen. How to make big platformer game with seamless camera transition to other location of the level map if action is on seen in that rectangle? Any ideas? Anyone?
Hello! Idk if u figured this out by now or not, but heres the solution to the question. Click (Project -> Project Settings -> AutoLoad) after this u can click the little folder icon right after the Path: text box and select what scrips u want to become a Singleton. After selecting click the Add button off to the right. Now it should be a singleton and accessible in the script for you. Hope this helps you out!
@@Arkeve Most welcome. I'm an almost complete Godot newbie. It's more of a side hobby off and on. I'm curious how do you have your player holding the sword?
How do i do this without the global.gd file that you have? I don't know how to define "Global" and thats the error that keep getting
As always Arkeve, incredible work. This is helping me so much!
Happy to help!
@@Arkeve Can You please tell me where you have got the sprite please...
For anyone wondering about the error "The identifier "Global" isn't declared in the current scope.":
Try changing your global.gd to uppercase Global.gd - it needs to be uppercase.
Also don't forget to put the Global.gd to autoload as Arkeve mentions in the video.
I have been trying to figure this out for hours, thank you so much!
Thanks for the help! can you think of any reason why the portal works on the initial scene but i cannot return once in the second scene?
edit I made it work. i just turned the layers and masks on and off until it worked. cant say i solved it.
Great dude. Your game design looks cool, when I watch a tutorial with a weird game, I'm always having doubts about the real talent of the dude.
This is probably too late to get a response but when I try to use Global.player_initial_map_position = player_spawn_location
in my Portal script for example I get an error saying "The identifier "Global" isn't declared in the current scope." Any help would be appreciated, thanks!
How to do handle having the player enter from 2 sides of a scene? For example if the player enters from the left of the mines or the right, would you just have 2 player nodes in the scene and hide depending on which side you've entered from?
Congratulations you have earned yourself a new subscriber
Trying to implement this into my game ( also thank you for being the only person to post a video on this!! ) but was wondering what is your global script attached to? I have a base world node and was wondering if i should put it on that or how to use the global script? Thanks for any help you can offer!!
You don't have to attach the global script to any node. You would have to make it an Autoload script though. Go to Project Settings -> Autoload tab and select the Global.gd script and click add. By making it an autoload script, the script automatically loads onto your scene tree and you should be able to access the script's variable in other scripts through: `Global.variable_name`
@@Arkeve Thank you so much for the quick response!! Gonna try it now, hopefully I can get it to work lol
Simple enough! Good tutorial. Now how about that sweet inventory and menu?
I'll make it my plan to make a video on it soon :)
@@Arkeve and so, a subscriber you have made out of me!
I'm wondering if it would work out to have invisible nodes in each scene to pinpoint the spawn locations. Then you'd have to reference that node by... a string, or something, I guess.
Really amazing tutorial, thank you.
Nice video bro 🙌 thank you so much
I know this is from at least a year ago, but I keep running into not being given the option of next scene path, I genuinely need some help with this-
I wonder in your game if you decided to add the cave part before you get to the cave, as a few intro tiles, to let you know you're entering into a new scene? I've seen that a lot since the 80s on various games, in NES. It builds anticipation of the next area.
Yup thats definitely a good idea!
@@Arkeve super :)
I know this goes kind of out of the scope of this tutorial, but I would personally prefer having some singleton managing the scene changes, and having it create a signal that can then be called by any node that wants a scene change, one of which could be the portal.
Great tutorial.
Clear and to the point.
Thanks a bunch!
"The identifier "Global" isn't declared in the current scope.'
This shows in both Player and Portal script. Setting the Global script to autoload in project settings, did nothing.
I've preload the script and = it to var Global. The previous error is gone but another shows !
"Invalid get index 'player_initial_map_position' {on base: 'GDScript'}"
Change to "var Global = load("res://Scene/Global.gd").new();" as suggested
on godotengine forums. When i put it in player script the game crashes on entering the portal.If added to both player and portal script, change scene works but teleports me in default position set in global script. I give up.
Hey, you shouldnt have to preload the global script. After setting it as an autoload script you should be able to access it in any script be "Global.variablename". It might have glitched when you first tried, try restarting the engine and accessing again. Hope it works!
Again if i don't make a variable Global in some way in Door and Player script Godot gives me error:
"The identifier "Global" isn't declared in the current scope.'
Player and or Door script seems to not see Global script even if autoloaded. Restarting Godot did nothing. Thanks for quick answer, maybe i find some other solution.
Holy shit, it worked! I just repeat every step once more from the start!!
I'm so sorry for pester you like this. But you are literally the only person on youtube who explain how to change scene with custom spawn points. Works like a charm!!
Thank you for these godot video tutorials :D I need all the help I can get, specially for 2D haha so I subbed ^^
Appreciate it!! I'm sure you'll start making some great 2D games! Keep learning!
Hey, thanks for all the help. I noticed you mentioned that if the game is top down, you have to worry about 4 directions. My game is top down. I tried implementing Vector2 in the facing directions but that didn't work. Can you help me out?
It really depends on how you implement movement in your game. I assume you change the player's direction depending on their velocity. But if you want to start the player in a certain direction, you can play the corresponding animation (idle direction animation) depending on a Vector2 value.
Vector2(1, 0) -> facing right
Vector2(-1, 0) -> facing left
Vector2(0, 1) -> facing down iirc
Vector2(0,-1) -> facing up.
In your player ready function, you load this Vector2 value from the Global.gd script and play the corresponding idle animation.
Amazing tutorial!! question: Can you have multiple portals? as in multiple exits that take you to different maps? I think it's possible to just add more portals but I haven't tested.
By having exportable variables you can indicate which scene and part of the map you want to go to. You should only load the string from the path of the specific scene
hmmm what if id want to have a the transition fluent/flawless/smooth instead of imidiate jump to different scenery. The ideal would be to have the camera and background follow the player in seamless long transition or even a huge, long map. But i have no idea how to do it. When working in Godot i can only see the rectangle that is limiting what player will see on the screen. How to make big platformer game with seamless camera transition to other location of the level map if action is on seen in that rectangle? Any ideas? Anyone?
Thank you for this tutorial, keep it up.
Error parsing expression, misplaced: Built-In Func
I'm getting this error
How did you change the game engine theme
I've followed the video but my player completely dissapears when I play the game, Does anyone know how I can fix this?
hi! what if I want to press a key before changing scenes? what part in the script do I add that key checker?
Worked great. Thanks.
thank you very much for this!
Nice video! How do you set it to remember the player costume and equipped items between scenes? Is it using the player's ready function?
Yup, i store what the player is wearing in an autoload script and set those sprites in the player's ready function
Great tutorial, thanks so much
Thank you, Good sir!
Looks good, thanks for sharing 👍
Thanks, appreciate it!
Amazing! thx !!
How can one add to the search "Godot Visual Script" and everything is in GDScript, why???? I just need one stupid button to switch scenes ahhhhh
Hello! Idk if u figured this out by now or not, but heres the solution to the question. Click (Project -> Project Settings -> AutoLoad) after this u can click the little folder icon right after the Path: text box and select what scrips u want to become a Singleton. After selecting click the Add button off to the right. Now it should be a singleton and accessible in the script for you. Hope this helps you out!
HOLY BASED!
FR
Awesome.. Thank you!! :D
Glad you found it helpful!!
@@Arkeve Most welcome. I'm an almost complete Godot newbie. It's more of a side hobby off and on. I'm curious how do you have your player holding the sword?
I create a separate sprite for the sword and then animate its position and rotation to align with the player's animation
@@Arkeve oh wow! So you can just change the weapon and replace it easily?
@@Arkeve I need to practice making more animated sprites. I only made one so far, an enemy that moves its eyes up and down while it walks. lol
OH! I just typing File and not FILE
That's why my exports were yelling at me!
thanks!! i don't speak english, but you help me 👍
Happy to help
hanks for sharing
Thanks for watching!
I had to make that my player died and it worked woth this tutorial i dont know how but it did
Thanks
It just work ^.^
this is so overly convoluted..