About attaching GameScene and Visual Script

Thank you for your message.

Regarding GameScene, my understanding is that as the game progresses through levels (e.g., Level 1, Level 2), we should create separate GameScenes such as GameScene_Level1, GameScene_Level2, and so on, with each scene containing its own objects. Is this correct?

Assuming this is correct, would it generally be better to use “Embedded Script” for Visual Scripts attached to objects like characters? If we don’t embed the Visual Script in the player of Level 1, then the player placed in Level 2 won’t have the Visual Script attached, right? While it’s possible to attach the Visual Script from Level 1 to the player in Level 2, this would be impractical for enemies that appear in large numbers.

I’ve also heard that there are some limitations with Embedded Scripts. I would appreciate it if you could explain the appropriate use cases for Embedded Visual Scripts versus those that are not embedded.

Yes. Each GameScene as a file. Godot Project Structure.

Use snake_case for folder and file names.

Example folder:

project 📁
    scenes 📁
        game_scene_1.tscn 🎬
        game_scene_2.tscn 🎬
        game_scene_3.tscn 🎬
    game_objects 📁
        player 📁
                player.tscn # GameObject
                player.vs
        enemies 📁
                slimes 📁
                    slime_1.tscn # GameObject
                    slime_2.tscn
                    slime.vs

Stored in .tscn:

[sub_resource type="VisualScript" id="VisualScript_o1b1i"]
data = {
"any_state_pos": Vector2(0, 0),
"base_type": &"GameObject",
"is_created_first_action_node": true,
"nodes": [
0, Vector2(-26.6667, 106.667), SubResource("VisualScriptAction_06ixh"), 
1, Vector2(186.667, 80), SubResource("VisualScriptAction_jgf6y"), 
2, Vector2(0, 0), SubResource("VisualScriptActionLink_d6fgq"), 
3, Vector2(0, 0), SubResource("VisualScriptActionLink_siowv"), 
4, Vector2(0, 0), SubResource("VisualScriptActionLink_rupok")],
"scroll": Vector2(-49.3939, -398)
}

Good for prototyping. Bad long term.

Game Scene Game Object Menu Scene Instantiated Game Object with Built-in Script
GameScene GameObject MenuScene Instantiated GameObject :clapper_board: with built-in script
![image 19x21, 100%](upload://xhJ3tPjHLREEc2ZWApaLqwu19Rl.png) ![image 22x17](upload://wHzWywLhQvPVQg4VCrcKUi73BPr.png)
:cross_mark: :warning: :cross_mark: :warning:
![image 234x378, 50%](upload://yi6wDGRw7CKfNYT7CA8Dl96vovP.png) ![image 227x187, 75%](upload://6EI7HSNkGDT6vrl96BLxfOtu6cR.png)

I would only use built-in scripts in GameObject scenes .tscn. I do not think it is good practice. I only do it for disposable prototypes.

I hope this helps.

1 Like

Thank you, Brasten.

I was surprised to receive a reply while I was in the middle of re-editing the original question text.
Thank you for your careful explanation, even going so far as to create a table. I’m not very smart, so I still can’t understand it, but I’ll take my time to look over it and think about what you taught me.
Thank you for your reply.

Thank you, Brasten.

I understand now regarding building scenes in the first half of the project folder. As expected, we will need to increase the number of game_scenes for each stage (surface), thank you.

Regarding the embedded scripts in the latter half, although you kindly explained them using images in table format, it seems difficult for me to grasp. However, I did understand that, except for prototype objects, it’s better not to use embedded scripts. I will take my time to study this further. Thank you.