Ship mostly works #10
Binary file not shown.
@ -41,41 +41,42 @@ func _ready():
|
||||
|
||||
|
||||
func _physics_process(_delta):
|
||||
if piloting_player.is_network_authority:
|
||||
if ship_is_piloted:
|
||||
var turn_speed = base_turn_speed / max(mass, 1)
|
||||
var lift_speed = base_lift_speed / max(mass, 1)
|
||||
|
||||
if Input.is_action_pressed("move_left"):
|
||||
angular_velocity.y += turn_speed
|
||||
elif Input.is_action_pressed("move_right"):
|
||||
angular_velocity.y -= turn_speed
|
||||
else:
|
||||
global_rotation.z = lerpf(global_rotation.z, 0, 0.8)
|
||||
|
||||
if Input.is_action_pressed("jump"):
|
||||
linear_velocity.y += lift_speed
|
||||
elif Input.is_action_pressed("crouch"):
|
||||
linear_velocity.y -= lift_speed
|
||||
|
||||
var target_velocity = Vector3.ZERO
|
||||
if Input.is_action_pressed("move_forwards"):
|
||||
target_velocity = -transform.basis.z * top_speed
|
||||
elif Input.is_action_pressed("move_backwards"):
|
||||
target_velocity = transform.basis.z * top_speed
|
||||
var current_acceleration = (target_velocity - linear_velocity) * acceleration
|
||||
apply_central_force(current_acceleration * mass)
|
||||
if linear_velocity.length() > top_speed:
|
||||
linear_velocity = linear_velocity.normalized() * top_speed
|
||||
|
||||
angular_velocity.y = clamp(angular_velocity.y, -max_turn_speed, max_turn_speed)
|
||||
if !piloting_player.is_network_authority: return
|
||||
if ship_is_piloted:
|
||||
var turn_speed = base_turn_speed / max(mass, 1)
|
||||
var lift_speed = base_lift_speed / max(mass, 1)
|
||||
|
||||
# Self level slowly
|
||||
global_rotation.x = lerpf(global_rotation.x, 0, 0.1)
|
||||
global_rotation.z = lerpf(global_rotation.z, 0, 0.1)
|
||||
if Input.is_action_pressed("move_left"):
|
||||
angular_velocity.y += turn_speed
|
||||
elif Input.is_action_pressed("move_right"):
|
||||
angular_velocity.y -= turn_speed
|
||||
else:
|
||||
global_rotation.z = lerpf(global_rotation.z, 0, 0.8)
|
||||
|
||||
# Networking
|
||||
if Input.is_action_pressed("jump"):
|
||||
linear_velocity.y += lift_speed
|
||||
elif Input.is_action_pressed("crouch"):
|
||||
linear_velocity.y -= lift_speed
|
||||
|
||||
var target_velocity = Vector3.ZERO
|
||||
if Input.is_action_pressed("move_forwards"):
|
||||
target_velocity = -transform.basis.z * top_speed
|
||||
elif Input.is_action_pressed("move_backwards"):
|
||||
target_velocity = transform.basis.z * top_speed
|
||||
var current_acceleration = (target_velocity - linear_velocity) * acceleration
|
||||
apply_central_force(current_acceleration * mass)
|
||||
if linear_velocity.length() > top_speed:
|
||||
linear_velocity = linear_velocity.normalized() * top_speed
|
||||
|
||||
angular_velocity.y = clamp(angular_velocity.y, -max_turn_speed, max_turn_speed)
|
||||
|
||||
# Self level slowly
|
||||
global_rotation.x = lerpf(global_rotation.x, 0, 0.1)
|
||||
global_rotation.z = lerpf(global_rotation.z, 0, 0.1)
|
||||
|
||||
if old_global_trans_cache != global_transform:
|
||||
NetworkManager.sync_property(uuid, "global_transform", global_transform)
|
||||
old_global_trans_cache = global_transform
|
||||
|
||||
|
||||
func _on_area_3d_body_entered(body: Node3D) -> void:
|
||||
|
BIN
godot-jolt/windows/~godot-jolt_windows-x64_editor.dll
Normal file
BIN
godot-jolt/windows/~godot-jolt_windows-x64_editor.dll
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user