WIP: Make it possible to change server address
This commit is contained in:
parent
e28845b688
commit
d2b89c9d5c
@ -35,6 +35,12 @@ offset_right = 224.0
|
|||||||
offset_bottom = 220.0
|
offset_bottom = 220.0
|
||||||
text = "Join"
|
text = "Join"
|
||||||
|
|
||||||
|
[node name="TextEdit" type="TextEdit" parent="."]
|
||||||
|
layout_mode = 0
|
||||||
|
offset_right = 8.0
|
||||||
|
offset_bottom = 8.0
|
||||||
|
text = "127.0.0.1"
|
||||||
|
|
||||||
[connection signal="player_connected" from="." to="." method="_on_player_connected"]
|
[connection signal="player_connected" from="." to="." method="_on_player_connected"]
|
||||||
[connection signal="player_disconnected" from="." to="." method="_on_player_disconnected"]
|
[connection signal="player_disconnected" from="." to="." method="_on_player_disconnected"]
|
||||||
[connection signal="server_disconnected" from="." to="." method="_on_server_disconnected"]
|
[connection signal="server_disconnected" from="." to="." method="_on_server_disconnected"]
|
||||||
|
@ -10,7 +10,7 @@ signal server_disconnected
|
|||||||
const PORT = 7000
|
const PORT = 7000
|
||||||
const DEFAULT_SERVER_IP = "127.0.0.1" # IPv4 localhost
|
const DEFAULT_SERVER_IP = "127.0.0.1" # IPv4 localhost
|
||||||
const MAX_CONNECTIONS = 20
|
const MAX_CONNECTIONS = 20
|
||||||
|
@onready var address_input: TextEdit = $TextEdit
|
||||||
var players = {}
|
var players = {}
|
||||||
var my_random_number = RandomNumberGenerator.new().randf_range(-2.0, 2.0)
|
var my_random_number = RandomNumberGenerator.new().randf_range(-2.0, 2.0)
|
||||||
var player_info = {"name": str(my_random_number)}
|
var player_info = {"name": str(my_random_number)}
|
||||||
@ -25,8 +25,7 @@ func _ready() -> void:
|
|||||||
multiplayer.server_disconnected.connect(_on_server_disconnected)
|
multiplayer.server_disconnected.connect(_on_server_disconnected)
|
||||||
|
|
||||||
func join_game(address = ""):
|
func join_game(address = ""):
|
||||||
if address.is_empty():
|
address = address_input.text
|
||||||
address = DEFAULT_SERVER_IP
|
|
||||||
var peer = ENetMultiplayerPeer.new()
|
var peer = ENetMultiplayerPeer.new()
|
||||||
var error = peer.create_client(address, PORT)
|
var error = peer.create_client(address, PORT)
|
||||||
if error:
|
if error:
|
||||||
|
@ -37,6 +37,9 @@ properties/0/replication_mode = 1
|
|||||||
properties/1/path = NodePath(".:rotation")
|
properties/1/path = NodePath(".:rotation")
|
||||||
properties/1/spawn = true
|
properties/1/spawn = true
|
||||||
properties/1/replication_mode = 1
|
properties/1/replication_mode = 1
|
||||||
|
properties/2/path = NodePath(".:rotation_order")
|
||||||
|
properties/2/spawn = true
|
||||||
|
properties/2/replication_mode = 1
|
||||||
|
|
||||||
[node name="Bullet" type="Node3D"]
|
[node name="Bullet" type="Node3D"]
|
||||||
transform = Transform3D(20, 0, 0, 0, 20, 0, 0, 0, 20, 0, 0, 0)
|
transform = Transform3D(20, 0, 0, 0, 20, 0, 0, 0, 20, 0, 0, 0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user