diff --git a/development/cpp/custom_audiostreams.rst b/development/cpp/custom_audiostreams.rst index 33d9095ac..251929b12 100644 --- a/development/cpp/custom_audiostreams.rst +++ b/development/cpp/custom_audiostreams.rst @@ -88,7 +88,7 @@ Therefore, playback state must be self-contained in AudioStreamPlayback. Ref AudioStreamMyTone::instance_playback() { Ref talking_tree; - talking_tree.instance(); + talking_tree.instantiate(); talking_tree->base = Ref(this); return talking_tree; } diff --git a/development/cpp/custom_resource_format_loaders.rst b/development/cpp/custom_resource_format_loaders.rst index 2098c250b..8ff0bab1c 100644 --- a/development/cpp/custom_resource_format_loaders.rst +++ b/development/cpp/custom_resource_format_loaders.rst @@ -337,10 +337,10 @@ when ``load`` is called. void register_json_types() { ClassDB::register_class(); - json_loader.instance(); + json_loader.instantiate(); ResourceLoader::add_resource_format_loader(json_loader); - json_saver.instance(); + json_saver.instantiate(); ResourceSaver::add_resource_format_saver(json_saver); } diff --git a/getting_started/first_3d_game/05.spawning_mobs.rst b/getting_started/first_3d_game/05.spawning_mobs.rst index 13a2a0ded..51f64d81a 100644 --- a/getting_started/first_3d_game/05.spawning_mobs.rst +++ b/getting_started/first_3d_game/05.spawning_mobs.rst @@ -236,7 +236,7 @@ Let's code the mob spawning logic. We're going to: func _on_MobTimer_timeout(): # Create a new instance of the Mob scene. - var mob = mob_scene.instance() + var mob = mob_scene.instantiate() # Choose a random location on the SpawnPath. # We store the reference to the SpawnLocation node. @@ -255,7 +255,7 @@ Let's code the mob spawning logic. We're going to: public void OnMobTimerTimeout() { // Create a new instance of the Mob scene. - Mob mob = (Mob)MobScene.Instance(); + Mob mob = (Mob)MobScene.Instantiate(); // Choose a random location on the SpawnPath. // We store the reference to the SpawnLocation node. @@ -288,7 +288,7 @@ Here is the complete ``Main.gd`` script so far, for reference. func _on_MobTimer_timeout(): - var mob = mob_scene.instance() + var mob = mob_scene.instantiate() var mob_spawn_location = get_node("SpawnPath/SpawnLocation") mob_spawn_location.unit_offset = randf() @@ -313,7 +313,7 @@ Here is the complete ``Main.gd`` script so far, for reference. public void OnMobTimerTimeout() { - Mob mob = (Mob)MobScene.Instance(); + Mob mob = (Mob)MobScene.Instantiate(); var mobSpawnLocation = GetNode("SpawnPath/SpawnLocation"); mobSpawnLocation.UnitOffset = GD.Randf(); diff --git a/getting_started/first_3d_game/07.killing_player.rst b/getting_started/first_3d_game/07.killing_player.rst index 1f1c6062f..1622e643c 100644 --- a/getting_started/first_3d_game/07.killing_player.rst +++ b/getting_started/first_3d_game/07.killing_player.rst @@ -166,7 +166,7 @@ Starting with ``Main.gd``. func _on_MobTimer_timeout(): # Create a new instance of the Mob scene. - var mob = mob_scene.instance() + var mob = mob_scene.instantiate() # Choose a random location on the SpawnPath. var mob_spawn_location = get_node("SpawnPath/SpawnLocation") @@ -201,7 +201,7 @@ Starting with ``Main.gd``. public void OnMobTimerTimeout() { // Create a new instance of the Mob scene. - var mob = (Mob)MobScene.Instance(); + var mob = (Mob)MobScene.Instantiate(); // Choose a random location on the SpawnPath. // We store the reference to the SpawnLocation node. diff --git a/getting_started/first_3d_game/08.score_and_replay.rst b/getting_started/first_3d_game/08.score_and_replay.rst index 1eaa719d8..2469b6bfb 100644 --- a/getting_started/first_3d_game/08.score_and_replay.rst +++ b/getting_started/first_3d_game/08.score_and_replay.rst @@ -388,7 +388,7 @@ Here is the complete ``Main.gd`` script for reference. func _on_MobTimer_timeout(): - var mob = mob_scene.instance() + var mob = mob_scene.instantiate() var mob_spawn_location = get_node("SpawnPath/SpawnLocation") mob_spawn_location.unit_offset = randf() @@ -429,7 +429,7 @@ Here is the complete ``Main.gd`` script for reference. public void OnMobTimerTimeout() { - Mob mob = (Mob)MobScene.Instance(); + Mob mob = (Mob)MobScene.Instantiate(); var mobSpawnLocation = GetNode("SpawnPath/SpawnLocation"); mobSpawnLocation.UnitOffset = GD.Randf(); diff --git a/tutorials/best_practices/scenes_versus_scripts.rst b/tutorials/best_practices/scenes_versus_scripts.rst index 0d3a83513..cc54552d5 100644 --- a/tutorials/best_practices/scenes_versus_scripts.rst +++ b/tutorials/best_practices/scenes_versus_scripts.rst @@ -30,8 +30,8 @@ a change in API: const MyScene = preload("my_scene.tscn") var node = Node.new() var my_node = MyNode.new() # Same method call - var my_scene = MyScene.instance() # Different method call - var my_inherited_scene = MyScene.instance(PackedScene.GEN_EDIT_STATE_MAIN) # Create scene inheriting from MyScene + var my_scene = MyScene.instantiate() # Different method call + var my_inherited_scene = MyScene.instantiate(PackedScene.GEN_EDIT_STATE_MAIN) # Create scene inheriting from MyScene .. code-tab:: csharp @@ -51,8 +51,8 @@ a change in API: { ANode = new Node(); MyNode = new MyNode(); // Same syntax - MyScene = MySceneScn.Instance(); // Different. Instantiated from a PackedScene - MyInheritedScene = MySceneScn.Instance(PackedScene.GenEditState.Main); // Create scene inheriting from MyScene + MyScene = MySceneScn.Instantiate(); // Different. Instantiated from a PackedScene + MyInheritedScene = MySceneScn.Instantiate(PackedScene.GenEditState.Main); // Create scene inheriting from MyScene } } @@ -217,4 +217,4 @@ In the end, the best approach is to consider the following: # main.gd extends Node func _ready(): - add_child(Game.MyScene.instance()) + add_child(Game.MyScene.instantiate()) diff --git a/tutorials/io/background_loading.rst b/tutorials/io/background_loading.rst index 1aa9a8e19..75a6457a3 100644 --- a/tutorials/io/background_loading.rst +++ b/tutorials/io/background_loading.rst @@ -192,7 +192,7 @@ loader. func set_new_scene(scene_resource): - current_scene = scene_resource.instance() + current_scene = scene_resource.instantiate() get_node("/root").add_child(current_scene) Using multiple threads @@ -285,7 +285,7 @@ Example: start_cutscene() # Later, when the user presses the pause button for the first time: - pause_menu = queue.get_resource("res://pause_menu.tres").instance() + pause_menu = queue.get_resource("res://pause_menu.tres").instantiate() pause_menu.show() # When you need a new scene: diff --git a/tutorials/io/saving_games.rst b/tutorials/io/saving_games.rst index 9a1575fc7..5ac6db4d7 100644 --- a/tutorials/io/saving_games.rst +++ b/tutorials/io/saving_games.rst @@ -241,7 +241,7 @@ load function: var node_data = json.get_data() # Firstly, we need to create the object and add it to the tree and set its position. - var new_object = load(node_data["filename"]).instance() + var new_object = load(node_data["filename"]).instantiate() get_node(node_data["parent"]).add_child(new_object) new_object.position = Vector2(node_data["pos_x"], node_data["pos_y"]) @@ -282,7 +282,7 @@ load function: // Firstly, we need to create the object and add it to the tree and set its position. var newObjectScene = (PackedScene)ResourceLoader.Load(nodeData["Filename"].ToString()); - var newObject = (Node)newObjectScene.Instance(); + var newObject = (Node)newObjectScene.Instantiate(); GetNode(nodeData["Parent"].ToString()).AddChild(newObject); newObject.Set("Position", new Vector2((float)nodeData["PosX"], (float)nodeData["PosY"])); diff --git a/tutorials/networking/high_level_multiplayer.rst b/tutorials/networking/high_level_multiplayer.rst index 79a9248d5..071aac203 100644 --- a/tutorials/networking/high_level_multiplayer.rst +++ b/tutorials/networking/high_level_multiplayer.rst @@ -309,18 +309,18 @@ every peer and RPC will work great! Here is an example: var selfPeerID = get_tree().get_network_unique_id() # Load world - var world = load(which_level).instance() + var world = load(which_level).instantiate() get_node("/root").add_child(world) # Load my player - var my_player = preload("res://player.tscn").instance() + var my_player = preload("res://player.tscn").instantiate() my_player.set_name(str(selfPeerID)) my_player.set_network_master(selfPeerID) # Will be explained later get_node("/root/world/players").add_child(my_player) # Load other players for p in player_info: - var player = preload("res://player.tscn").instance() + var player = preload("res://player.tscn").instantiate() player.set_name(str(p)) player.set_network_master(p) # Will be explained later get_node("/root/world/players").add_child(player) @@ -392,14 +392,14 @@ If you have paid attention to the previous example, it's possible you noticed th [...] # Load my player - var my_player = preload("res://player.tscn").instance() + var my_player = preload("res://player.tscn").instantiate() my_player.set_name(str(selfPeerID)) my_player.set_network_master(selfPeerID) # The player belongs to this peer; it has the authority. get_node("/root/world/players").add_child(my_player) # Load other players for p in player_info: - var player = preload("res://player.tscn").instance() + var player = preload("res://player.tscn").instantiate() player.set_name(str(p)) player.set_network_master(p) # Each other connected peer has authority over their own player. get_node("/root/world/players").add_child(player) diff --git a/tutorials/performance/thread_safe_apis.rst b/tutorials/performance/thread_safe_apis.rst index 85e5964ab..b93f92cbf 100644 --- a/tutorials/performance/thread_safe_apis.rst +++ b/tutorials/performance/thread_safe_apis.rst @@ -35,7 +35,7 @@ However, creating scene chunks (nodes in tree arrangement) outside the active tr :: var enemy_scene = load("res://enemy_scene.scn") - var enemy = enemy_scene.instance() + var enemy = enemy_scene.instantiate() enemy.add_child(weapon) # Set a weapon. world.call_deferred("add_child", enemy) diff --git a/tutorials/physics/using_character_body_2d.rst b/tutorials/physics/using_character_body_2d.rst index ed8ff691f..1ac92939f 100644 --- a/tutorials/physics/using_character_body_2d.rst +++ b/tutorials/physics/using_character_body_2d.rst @@ -343,7 +343,7 @@ uses the mouse pointer. Here is the code for the Player, using ``move_and_slide( func shoot(): # "Muzzle" is a Marker2D placed at the barrel of the gun. - var b = Bullet.instance() + var b = Bullet.instantiate() b.start($Muzzle.global_position, rotation) get_parent().add_child(b) @@ -387,7 +387,7 @@ uses the mouse pointer. Here is the code for the Player, using ``move_and_slide( public void Shoot() { // "Muzzle" is a Marker2D placed at the barrel of the gun - var b = (Bullet)_bullet.Instance(); + var b = (Bullet)_bullet.Instantiate(); b.Start(GetNode("Muzzle").GlobalPosition, Rotation); GetParent().AddChild(b); } diff --git a/tutorials/scripting/change_scenes_manually.rst b/tutorials/scripting/change_scenes_manually.rst index 4402b3d95..f2d6ccd11 100644 --- a/tutorials/scripting/change_scenes_manually.rst +++ b/tutorials/scripting/change_scenes_manually.rst @@ -12,7 +12,7 @@ scenes which one instances and adds to the tree at runtime: .. tabs:: .. code-tab:: gdscript GDScript - var simultaneous_scene = preload("res://levels/level2.tscn").instance() + var simultaneous_scene = preload("res://levels/level2.tscn").instantiate() func _add_a_scene_manually(): # This is like autoloading the scene, only @@ -25,7 +25,7 @@ scenes which one instances and adds to the tree at runtime: public MyClass() { - simultaneousScene = ResourceLoader.Load("res://levels/level2.tscn").Instance(); + simultaneousScene = ResourceLoader.Load("res://levels/level2.tscn").Instantiate(); } public void _AddASceneManually() diff --git a/tutorials/scripting/instancing_with_signals.rst b/tutorials/scripting/instancing_with_signals.rst index 8c9372f1e..4a44fc074 100644 --- a/tutorials/scripting/instancing_with_signals.rst +++ b/tutorials/scripting/instancing_with_signals.rst @@ -68,7 +68,7 @@ You could do this by adding the bullet to the main scene directly: .. code-tab:: csharp - Node bulletInstance = Bullet.Instance(); + Node bulletInstance = Bullet.Instantiate(); GetParent().AddChild(bulletInstance); However, this will lead to a different problem. Now if you try to test your @@ -145,7 +145,7 @@ In the main scene, we then connect the player's signal (it will appear in the public void _on_Player_Shoot(PackedScene bullet, Vector2 direction, Vector2 location) { - var bulletInstance = (Bullet)bullet.Instance(); + var bulletInstance = (Bullet)bullet.Instantiate(); AddChild(bulletInstance); bulletInstance.Rotation = direction; bulletInstance.Position = location; diff --git a/tutorials/scripting/resources.rst b/tutorials/scripting/resources.rst index 7898dbbe3..b9b4a6a38 100644 --- a/tutorials/scripting/resources.rst +++ b/tutorials/scripting/resources.rst @@ -132,7 +132,7 @@ To get an instance of the scene, you have to use the public void OnShoot() { - Node bullet = _bulletScene.Instance(); + Node bullet = _bulletScene.Instantiate(); AddChild(bullet); } diff --git a/tutorials/scripting/singletons_autoload.rst b/tutorials/scripting/singletons_autoload.rst index 2861360bb..9691b8b4f 100644 --- a/tutorials/scripting/singletons_autoload.rst +++ b/tutorials/scripting/singletons_autoload.rst @@ -203,7 +203,7 @@ current scene and replace it with the requested one. var s = ResourceLoader.load(path) # Instance the new scene. - current_scene = s.instance() + current_scene = s.instantiate() # Add it to the active scene, as child of root. get_tree().root.add_child(current_scene) @@ -236,7 +236,7 @@ current scene and replace it with the requested one. var nextScene = (PackedScene)GD.Load(path); // Instance the new scene. - CurrentScene = nextScene.Instance(); + CurrentScene = nextScene.Instantiate(); // Add it to the active scene, as child of root. GetTree().Root.AddChild(CurrentScene);