Update all instances of instance() to instantiate()

This commit is contained in:
Hugo Locurcio
2022-11-29 16:58:44 +01:00
parent f133c1ce64
commit 509804650e
15 changed files with 35 additions and 35 deletions

View File

@@ -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)