WIP: Try another implementation
This commit is contained in:
parent
fe08da9d4c
commit
2577c032fd
16
game_server_manager.gd
Normal file
16
game_server_manager.gd
Normal file
@ -0,0 +1,16 @@
|
||||
extends Node
|
||||
|
||||
var players := {}
|
||||
|
||||
func add_player(id: int, name: String):
|
||||
if ! players.has(id):
|
||||
players[id] = {"name": name}
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
pass
|
@ -6,12 +6,14 @@ var player_side: String
|
||||
@onready var intro_view_port = $Intro/CameraMount/IntroCamera/SubViewportContainer/SubViewport
|
||||
@onready var spawns = $Spawns
|
||||
@onready var root = $'.'
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
var char : Node3D = null
|
||||
var red_spawn: Node3D = $Spawns/Blue/SpawnArea
|
||||
var position := red_spawn.global_position
|
||||
char = ResourceLoader.load("res://scenes/utils/character.tscn").instantiate()
|
||||
char.name = str(multiplayer.get_unique_id())
|
||||
char.global_position = position
|
||||
root.add_child(char)
|
||||
pass
|
||||
|
@ -24,3 +24,7 @@ size = Vector3(0.100647, 1, 6.02112)
|
||||
[node name="SpawnArea" type="CSGBox3D" parent="Spawns/Blue"]
|
||||
transform = Transform3D(5.70162, 0, 0, 0, 1, 0, 0, 0, 7.97817, 21.2099, 1.78438, 1.23551)
|
||||
size = Vector3(0.484497, 1, 5.99213)
|
||||
|
||||
[node name="MultiplayerSpawner" type="MultiplayerSpawner" parent="."]
|
||||
_spawnable_scenes = PackedStringArray("res://scenes/utils/character.tscn")
|
||||
spawn_path = NodePath("../Spawns/Red/SpawnArea")
|
||||
|
@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=6 format=3 uid="uid://ccm77j5rkh21w"]
|
||||
[gd_scene load_steps=7 format=3 uid="uid://ccm77j5rkh21w"]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/character_controller.gd" id="1_sue4n"]
|
||||
[ext_resource type="PackedScene" uid="uid://bmqutwuj28san" path="res://scenes/utils/view_model_camera.tscn" id="4_al83x"]
|
||||
@ -9,6 +9,11 @@
|
||||
radius = 0.368364
|
||||
height = 1.8
|
||||
|
||||
[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_csl3n"]
|
||||
properties/0/path = NodePath(".:position")
|
||||
properties/0/spawn = true
|
||||
properties/0/replication_mode = 1
|
||||
|
||||
[node name="Character" type="Node3D"]
|
||||
|
||||
[node name="CharacterBody3D" type="CharacterBody3D" parent="."]
|
||||
@ -30,3 +35,6 @@ script = ExtResource("4_uwcjh")
|
||||
transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, -0.0287516, -0.136104, -0.276055)
|
||||
visible = false
|
||||
script = null
|
||||
|
||||
[node name="MultiplayerSynchronizer" type="MultiplayerSynchronizer" parent="."]
|
||||
replication_config = SubResource("SceneReplicationConfig_csl3n")
|
||||
|
@ -39,7 +39,7 @@ func _on_host_pressed() -> void:
|
||||
|
||||
players[1] = player_info
|
||||
player_connected.emit(1, player_info)
|
||||
|
||||
game_server_manager.add_player(1, "host")
|
||||
|
||||
func remove_multiplayer_peer():
|
||||
multiplayer.multiplayer_peer = null
|
||||
|
Loading…
x
Reference in New Issue
Block a user