WIP: Modifying the client node
This commit is contained in:
21
godot/scenes/utils/camera_mount/camera_mount.gd
Normal file
21
godot/scenes/utils/camera_mount/camera_mount.gd
Normal file
@ -0,0 +1,21 @@
|
||||
extends Node3D
|
||||
class_name CameraMount
|
||||
|
||||
# -- When camera mount is not active, client shouldn't connect to it
|
||||
@export var active: bool = false
|
||||
@export var default: bool = false
|
||||
|
||||
var camera: Camera3D
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
camera = Camera3D.new()
|
||||
add_child(camera)
|
||||
|
||||
@rpc("any_peer", "call_local", "reliable")
|
||||
func connect_to_camera() -> void :
|
||||
if active:
|
||||
camera.make_current()
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
pass
|
6
godot/scenes/utils/camera_mount/camera_mount.tscn
Normal file
6
godot/scenes/utils/camera_mount/camera_mount.tscn
Normal file
@ -0,0 +1,6 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://316q8oy76ev1"]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/utils/camera_mount/camera_mount.gd" id="1_5dtrj"]
|
||||
|
||||
[node name="CameraMount" type="Node3D"]
|
||||
script = ExtResource("1_5dtrj")
|
16
godot/scenes/utils/client_node/client_node.gd
Normal file
16
godot/scenes/utils/client_node/client_node.gd
Normal file
@ -0,0 +1,16 @@
|
||||
extends Node3D
|
||||
class_name ClientNode
|
||||
|
||||
|
||||
var available_cameras: Array[CameraMount] = []
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _physics_process(delta: float) -> void:
|
||||
var game_root := helpers.get_root_node()
|
||||
var available_cameras_raw: Array[Node] = game_root.find_children("*", "CameraMount", true, false)
|
||||
for camera_raw in available_cameras_raw:
|
||||
var camera: CameraMount = camera_raw as CameraMount
|
||||
if camera.active:
|
||||
camera.connect_to_camera()
|
||||
available_cameras.append(camera)
|
||||
|
6
godot/scenes/utils/client_node/client_node.tscn
Normal file
6
godot/scenes/utils/client_node/client_node.tscn
Normal file
@ -0,0 +1,6 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://b4y8gnogfoulk"]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/utils/client_node/client_node.gd" id="1_otqq8"]
|
||||
|
||||
[node name="ClientNode" type="Node3D"]
|
||||
script = ExtResource("1_otqq8")
|
@ -1,6 +1,7 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://f3lbhroreypw"]
|
||||
[gd_scene load_steps=3 format=3 uid="uid://f3lbhroreypw"]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/utils/game_root/game_root.gd" id="1_ogtsj"]
|
||||
[ext_resource type="Script" path="res://scenes/utils/client_node/client_node.gd" id="2_75551"]
|
||||
|
||||
[node name="GameRoot" type="Node"]
|
||||
script = ExtResource("1_ogtsj")
|
||||
@ -14,4 +15,7 @@ spawn_limit = 1
|
||||
|
||||
[node name="Level" type="Node3D" parent="."]
|
||||
|
||||
[node name="ClientNode" type="Node3D" parent="."]
|
||||
script = ExtResource("2_75551")
|
||||
|
||||
[connection signal="load_map" from="." to="." method="_on_load_map"]
|
||||
|
Reference in New Issue
Block a user