Preliminary multiplayer capability (origin stuff disabled for now)
This commit is contained in:
parent
73baafbd6c
commit
f0c4263675
18 changed files with 704 additions and 99 deletions
|
@ -6,6 +6,11 @@ extends CharacterBody3D
|
|||
|
||||
@export var initial_speed: float
|
||||
|
||||
@export var multiplayer_authority := 1 :
|
||||
set(id):
|
||||
multiplayer_authority = id
|
||||
set_multiplayer_authority.call_deferred(id)
|
||||
|
||||
#var acceleration := Vector3
|
||||
#var angular_velocity := Vector3
|
||||
#var angular_acceleration := Vector3
|
||||
|
@ -22,8 +27,8 @@ var m_is_landed := false
|
|||
func _ready() -> void:
|
||||
velocity = -global_basis.z * initial_speed
|
||||
m_relative_velocity = transform.basis.inverse() * velocity
|
||||
m_tas = _tas()
|
||||
m_ias = _ias()
|
||||
m_tas = _tas(m_relative_velocity)
|
||||
m_ias = _ias(m_relative_velocity)
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
|
||||
|
@ -34,8 +39,8 @@ func _physics_process(delta: float) -> void:
|
|||
m_sideslip = -atan2(m_relative_velocity.x, -m_relative_velocity.z)
|
||||
if m_sideslip > PI:
|
||||
m_sideslip -= TAU
|
||||
m_tas = _tas()
|
||||
m_ias = _ias()
|
||||
m_tas = _tas(m_relative_velocity)
|
||||
m_ias = _ias(m_relative_velocity)
|
||||
|
||||
# aero
|
||||
var vel_forward := m_relative_velocity.normalized()
|
||||
|
@ -79,14 +84,20 @@ func _physics_process(delta: float) -> void:
|
|||
rotate_object_local(steering_axis.normalized(), steering_axis.length())
|
||||
|
||||
move_and_slide()
|
||||
m_region_transform.sync_from_transform()
|
||||
#m_region_transform.sync_from_transform()
|
||||
#if !is_landed:
|
||||
# _fly()
|
||||
#else:
|
||||
# taxi()
|
||||
#ResetControls()
|
||||
|
||||
#func _sync()
|
||||
@rpc("authority", "call_remote", "unreliable_ordered")
|
||||
func _sync(pos: Vector3, rot: Basis, vel: Vector3, steering_axis: Vector3) -> void:
|
||||
# Don't snap to the correct location, because that will look bad.
|
||||
# Instead, just nudge it in the right direction.
|
||||
#var rtt: float = multiplayer.get_peers().
|
||||
#transform.basis = rot.rotated(steering_axis.normalized(), steering_axis.length() * )
|
||||
pass
|
||||
|
||||
func _get_steering_axis() -> Vector3:
|
||||
var pitch_effect := Vector3.RIGHT * performance.pitch_power.sample(absf(rad_to_deg(m_aoa))) * controller.pitch
|
||||
|
@ -192,11 +203,11 @@ func _thrust() -> float:
|
|||
# mAngularVelocity = new Vector3(horizAirfoil.getMoment(degAoA) * horizLiftPerCoeff, vertAirfoil.getMoment(degSideslip) * vertLiftPerCoeff, 0f);
|
||||
# mAngularVelocity += new Vector3(-moment * Mathf.Cos(Vector3.Angle(Physics.gravity, transform.up) * Mathf.Deg2Rad) * horizLiftPerCoeff, 0.0f, 0.0f)
|
||||
|
||||
func _tas() -> float:
|
||||
return sqrt(m_relative_velocity.z * m_relative_velocity.z + m_relative_velocity.y * m_relative_velocity.y) * -sign(m_relative_velocity.z)
|
||||
func _tas(relative_velocity: Vector3) -> float:
|
||||
return relative_velocity.length() * -sign(relative_velocity.z)
|
||||
|
||||
func _ias() -> float:
|
||||
return _tas() * sqrt(Atmosphere.density_by_alt(position.y, true))
|
||||
func _ias(relative_velocity: Vector3) -> float:
|
||||
return _tas(relative_velocity) * sqrt(Atmosphere.density_by_alt(position.y, true))
|
||||
|
||||
#func _
|
||||
|
||||
|
|
|
@ -15,7 +15,13 @@ extends AircraftController
|
|||
@export var roll_speed := 1.0
|
||||
@export var throttle_speed := 1.0
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
#func _ready() -> void:
|
||||
# Only process for the local player.
|
||||
# set_process(get_multiplayer_authority() == multiplayer.get_unique_id())
|
||||
# if get_multiplayer_authority() == multiplayer.get_unique_id():
|
||||
# print("Multiplayer auth: ", str(get_multiplayer_authority()))
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if get_multiplayer_authority() == multiplayer.get_unique_id():
|
||||
var pitch_target := Input.get_axis(pitch_down, pitch_up)
|
||||
var pitch_diff := pitch_target - pitch
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue