increase ship's overall speed, correct player head syncing

This commit is contained in:
Gary Steven Keough 2024-12-28 19:59:30 -05:00
parent ec6325fb9e
commit d0a2a74e14
3 changed files with 19 additions and 21 deletions

View File

@ -53,11 +53,16 @@ func _ready() -> void:
body.hide() body.hide()
head.hide() head.hide()
player_avatar_face.hide() player_avatar_face.hide()
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
func _unhandled_input(event: InputEvent) -> void: func _input(event):
if !is_network_authority: return if !is_network_authority: return
if event.is_action_pressed("esc") and Input.mouse_mode == Input.MOUSE_MODE_CAPTURED:
release_mouse()
elif event.is_action_pressed("esc") and not Input.mouse_mode == Input.MOUSE_MODE_CAPTURED:
capture_mouse()
if Input.mouse_mode == Input.MOUSE_MODE_CAPTURED: if Input.mouse_mode == Input.MOUSE_MODE_CAPTURED:
if event is InputEventMouseMotion: if event is InputEventMouseMotion:
is_using_joystick = false is_using_joystick = false
@ -65,17 +70,10 @@ func _unhandled_input(event: InputEvent) -> void:
_rotate_camera() _rotate_camera()
elif event is InputEventJoypadMotion: elif event is InputEventJoypadMotion:
is_using_joystick = true is_using_joystick = true
if Input.is_action_just_pressed("jump") and !is_piloting: if Input.is_action_just_pressed("jump") and !is_piloting:
jumping = true jumping = true
func _input(event):
if !is_network_authority: return
if event.is_action_pressed("esc") and Input.mouse_mode == Input.MOUSE_MODE_CAPTURED:
release_mouse()
elif event.is_action_pressed("esc") and not Input.mouse_mode == Input.MOUSE_MODE_CAPTURED:
capture_mouse()
func _physics_process(delta: float) -> void: func _physics_process(delta: float) -> void:
if !is_network_authority: return if !is_network_authority: return
@ -104,9 +102,9 @@ func _process(delta: float) -> void:
NetworkManager.sync_property(network_uuid, "global_rotation", global_rotation) NetworkManager.sync_property(network_uuid, "global_rotation", global_rotation)
previous_global_rotation = global_rotation previous_global_rotation = global_rotation
if previous_head_vert_rotation != neck.global_rotation: if previous_head_vert_rotation != neck.rotation:
NetworkManager.sync_property(network_uuid, "neck_rotation_sync", neck_rotation_sync) NetworkManager.sync_property(network_uuid, "neck_rotation_sync", neck_rotation_sync)
previous_global_rotation = neck.global_rotation previous_global_rotation = neck.rotation
func capture_mouse() -> void: func capture_mouse() -> void:
@ -191,8 +189,8 @@ func ship_exited():
func _on_property_update(node_id: String, property_name: String, value: Variant) -> void: func _on_property_update(node_id: String, property_name: String, value: Variant) -> void:
if NetworkManager.node_map.has(node_id): if NetworkManager.node_map.has(node_id):
if property_name == "neck_rotation_sync": if property_name == "neck_rotation_sync" and !is_network_authority:
neck.global_rotation = value neck.rotation = value
else: else:
var node = NetworkManager.node_map[node_id] var node = NetworkManager.node_map[node_id]
node.set(property_name, value) node.set(property_name, value)

View File

@ -8,12 +8,12 @@ extends RigidBody3D
var piloting_player: Player = null var piloting_player: Player = null
var ship_is_piloted: bool = false var ship_is_piloted: bool = false
@export var base_turn_speed: float = 10.0 @export var base_turn_speed: float = 50.0
@export var max_turn_speed: float = 10.0 @export var max_turn_speed: float = 50.0
@export var base_lift_speed: float = 20.0 @export var base_lift_speed: float = 50.0
@export var top_speed: float = 30.0 @export var top_speed: float = 50.0
@export var move_speed: float = 15.0 @export var move_speed: float = 50.0
@export var acceleration: float = 5.0 @export var acceleration: float = 50.0
# Networking # Networking
var network_uuid: String = "" var network_uuid: String = ""
@ -22,6 +22,7 @@ var target_rotation: Quaternion = Quaternion()
var previous_position: Vector3 var previous_position: Vector3
var previous_rotation: Quaternion var previous_rotation: Quaternion
func _ready(): func _ready():
network_uuid = NetworkManager.register_node(self) network_uuid = NetworkManager.register_node(self)
target_position = global_position target_position = global_position

View File

@ -26,7 +26,6 @@ script = ExtResource("1_ghft7")
player_detection_area = NodePath("PlayerDetectionArea") player_detection_area = NodePath("PlayerDetectionArea")
helm_location_marker = NodePath("HelmLocationMarker") helm_location_marker = NodePath("HelmLocationMarker")
base_lift_speed = 5.0 base_lift_speed = 5.0
top_speed = 50.0
[node name="ShipToShipCol" type="CollisionShape3D" parent="."] [node name="ShipToShipCol" type="CollisionShape3D" parent="."]
shape = SubResource("BoxShape3D_6gbwt") shape = SubResource("BoxShape3D_6gbwt")