Fix the sync and add shooting
This commit is contained in:
@ -6,6 +6,7 @@
|
||||
script = ExtResource("1_ohxtg")
|
||||
|
||||
[node name="MultiplayerSpawner" type="MultiplayerSpawner" parent="."]
|
||||
_spawnable_scenes = PackedStringArray("res://scenes/weapon/bullet.tscn")
|
||||
spawn_path = NodePath("../Bullets")
|
||||
|
||||
[node name="Bullets" type="Node3D" parent="."]
|
||||
|
@ -48,17 +48,21 @@ func _request_spawn():
|
||||
|
||||
func _spawn_player(id: int):
|
||||
player_spawner.spawn_players(spawn_locations, id)
|
||||
_spawn_player_controller_node.rpc_id(id)
|
||||
var controlled_node: ServerNode = player_spawner.get_player_node(id)
|
||||
var position := controlled_node.shared_node.global_position
|
||||
_spawn_player_controller_node.rpc_id(id, position.x, position.y, position.z)
|
||||
|
||||
@rpc("any_peer", "call_local", "reliable")
|
||||
func _spawn_player_controller_node():
|
||||
func _spawn_player_controller_node(x: float, y: float, z: float):
|
||||
var path := "res://scenes/player/player_node.tscn"
|
||||
var scene: PackedScene = ResourceLoader.load(path)
|
||||
var player_node: PlayerInputController = scene.instantiate()
|
||||
var player_node: PlayerNode = scene.instantiate()
|
||||
player_node.name = "PlayerController"
|
||||
var controlled_node: ServerNode = player_spawner.get_player_node(multiplayer.get_unique_id())
|
||||
player_node.controlled_node = controlled_node
|
||||
client_node.add_child(player_node)
|
||||
player_node.initial_position_sync()
|
||||
player_node.shared_node.global_position = Vector3(x,y,z)
|
||||
controlled_node.bind_player_node()
|
||||
|
||||
|
||||
func _remove_player(id: int):
|
||||
|
@ -18,7 +18,6 @@ func spawn_players(spawn_location: SpawnController, id: int) -> Error:
|
||||
char.owner_id = id
|
||||
_get_root().add_child(char)
|
||||
char.shared_node.global_position = new_position
|
||||
print(new_position)
|
||||
return OK
|
||||
return ERR_UNAUTHORIZED
|
||||
|
||||
|
@ -0,0 +1,11 @@
|
||||
extends Node
|
||||
|
||||
|
||||
# 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
|
@ -0,0 +1,8 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://bbqh8e8t0rvwj"]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/maps/base/player_synchronizer/player_synchronizer.gd" id="1_cam4s"]
|
||||
|
||||
[node name="PlayerSynchronizer" type="Node"]
|
||||
script = ExtResource("1_cam4s")
|
||||
|
||||
[node name="Timer" type="Timer" parent="."]
|
Reference in New Issue
Block a user