You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
491 B
GDScript
22 lines
491 B
GDScript
2 years ago
|
extends Node
|
||
|
|
||
|
var network = NetworkedMultiplayerENet.new()
|
||
|
var ip = "127.0.0.1"
|
||
|
var port = 3000
|
||
|
|
||
|
func connect_to_server():
|
||
|
network.create_client(ip, port)
|
||
|
get_tree().set_network_peer(network)
|
||
|
network.connect("connection_failed", self, "_connection_failed")
|
||
|
network.connect("connection_succeeded", self, "_connection_succeeded")
|
||
|
|
||
|
func _connection_failed():
|
||
|
print_debug("Failed to connect")
|
||
|
|
||
|
func _connection_succeeded():
|
||
|
print_debug("Connected")
|
||
|
|
||
|
func _ready():
|
||
|
connect_to_server()
|
||
|
|