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,20 +53,7 @@ func _ready() -> void:
body.hide()
head.hide()
player_avatar_face.hide()
func _unhandled_input(event: InputEvent) -> void:
if !is_network_authority: return
if Input.mouse_mode == Input.MOUSE_MODE_CAPTURED:
if event is InputEventMouseMotion:
is_using_joystick = false
look_dir = event.relative * 0.001
_rotate_camera()
elif event is InputEventJoypadMotion:
is_using_joystick = true
if Input.is_action_just_pressed("jump") and !is_piloting:
jumping = true
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
func _input(event):
@ -76,6 +63,17 @@ func _input(event):
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 event is InputEventMouseMotion:
is_using_joystick = false
look_dir = event.relative * 0.001
_rotate_camera()
elif event is InputEventJoypadMotion:
is_using_joystick = true
if Input.is_action_just_pressed("jump") and !is_piloting:
jumping = true
func _physics_process(delta: float) -> void:
if !is_network_authority: return
@ -104,9 +102,9 @@ func _process(delta: float) -> void:
NetworkManager.sync_property(network_uuid, "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)
previous_global_rotation = neck.global_rotation
previous_global_rotation = neck.rotation
func capture_mouse() -> void:
@ -191,8 +189,8 @@ func ship_exited():
func _on_property_update(node_id: String, property_name: String, value: Variant) -> void:
if NetworkManager.node_map.has(node_id):
if property_name == "neck_rotation_sync":
neck.global_rotation = value
if property_name == "neck_rotation_sync" and !is_network_authority:
neck.rotation = value
else:
var node = NetworkManager.node_map[node_id]
node.set(property_name, value)

View File

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

View File

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