Ship mostly works #10
@ -37,6 +37,8 @@ var previous_global_position: Vector3
|
||||
var previous_global_rotation: Vector3
|
||||
var previous_head_vert_rotation: Vector3
|
||||
|
||||
var neck_rotation_sync: Vector3
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
NetworkManager.property_update_received.connect(_on_property_update)
|
||||
@ -97,11 +99,13 @@ func _process(delta: float) -> void:
|
||||
if previous_global_position != global_position:
|
||||
NetworkManager.sync_property(network_uuid, "global_position", global_position)
|
||||
previous_global_position = global_position
|
||||
|
||||
if previous_global_rotation != global_rotation:
|
||||
NetworkManager.sync_property(network_uuid, "global_rotation", global_rotation)
|
||||
previous_global_rotation = global_rotation
|
||||
|
||||
if previous_head_vert_rotation != neck.global_rotation:
|
||||
NetworkManager.sync_property(network_uuid, "neck.global_rotation", neck.global_rotation)
|
||||
NetworkManager.sync_property(network_uuid, "neck_rotation_sync", neck_rotation_sync)
|
||||
previous_global_rotation = neck.global_rotation
|
||||
|
||||
|
||||
@ -123,6 +127,7 @@ func _rotate_camera(sens_mod: float = 1.0) -> void:
|
||||
|
||||
rotation.y -= look_dir.x * camera_sens_final * sens_mod
|
||||
neck.rotation.x = clamp(neck.rotation.x - look_dir.y * camera_sens_final * sens_mod, -1.5, 1.5)
|
||||
neck_rotation_sync = neck.rotation
|
||||
|
||||
|
||||
func _handle_joypad_camera_rotation(delta: float, sens_mod: float = 1.0) -> void:
|
||||
@ -186,7 +191,10 @@ func ship_exited():
|
||||
|
||||
func _on_property_update(node_id: String, property_name: String, value: Variant) -> void:
|
||||
if NetworkManager.node_map.has(node_id):
|
||||
var node = NetworkManager.node_map[node_id]
|
||||
node.set(property_name, value)
|
||||
if property_name == "neck_rotation_sync":
|
||||
neck.global_rotation = value
|
||||
else:
|
||||
var node = NetworkManager.node_map[node_id]
|
||||
node.set(property_name, value)
|
||||
else:
|
||||
printerr("Received property update but node_id is wrong? Expected " + str(network_uuid) + " but got " + str(node_id))
|
||||
|
@ -8,12 +8,12 @@ extends RigidBody3D
|
||||
var piloting_player: Player = null
|
||||
var ship_is_piloted: bool = false
|
||||
|
||||
@export var base_turn_speed: float = 0.35
|
||||
@export var max_turn_speed: float = 0.5
|
||||
@export var base_lift_speed: float = 2.0
|
||||
@export var top_speed: float = 5.0
|
||||
@export var move_speed: float = 1.0
|
||||
@export var acceleration: float = 0.1
|
||||
@export var base_turn_speed: float = 10.0
|
||||
@export var max_turn_speed: float = 10.0
|
||||
@export var base_lift_speed: float = 20.0
|
||||
@export var top_speed: float = 30.0
|
||||
@export var move_speed: float = 15.0
|
||||
@export var acceleration: float = 5.0
|
||||
|
||||
# Networking
|
||||
var network_uuid: String = ""
|
||||
@ -41,7 +41,7 @@ func _process(delta: float):
|
||||
else:
|
||||
interpolate_position_and_rotation(delta)
|
||||
|
||||
func handle_input(delta: float):
|
||||
func handle_input(_delta: float):
|
||||
var forward_input = 0.0
|
||||
var turn_input = 0.0
|
||||
var vertical_input = 0.0
|
||||
|
Loading…
Reference in New Issue
Block a user