WIP: Migrating to node3ds
This commit is contained in:
parent
e77a828fca
commit
556f0dbb27
@ -5,7 +5,7 @@ class_name CharacterWrapper
|
||||
@export var owner_placeholder: CharacterBody3D = null
|
||||
|
||||
@export var server_node: Node3D # The real synced node from the server
|
||||
@export var interpolation_delay: float = 0.01 # Stay 100ms behind for smooth interpolation
|
||||
@export var interpolation_delay: float = 0.1 # Stay 100ms behind for smooth interpolation
|
||||
@export var snap_threshold: float = 2.0 # If desync is larger than this, snap instantly
|
||||
|
||||
var position_buffer = [] # Stores past positions (tuples of (timestamp, position, rotation))
|
||||
|
@ -57,12 +57,10 @@ func _physics_process(delta: float) -> void:
|
||||
shared_node.velocity.z = move_toward(shared_node.velocity.z, 0, consts.DEFAULT_CHARACTER_SPEED)
|
||||
shared_node.move_and_slide()
|
||||
|
||||
|
||||
|
||||
@rpc("authority", "call_remote", "unreliable_ordered")
|
||||
func update_position(real_position: Vector3):
|
||||
if not multiplayer.is_server():
|
||||
shared_node.global_position = lerp(shared_node.global_position, real_position, 1.0)
|
||||
shared_node.global_transform.origin = lerp(shared_node.global_transform.origin, real_position, 1.0)
|
||||
|
||||
@rpc("any_peer", "call_local", "unreliable")
|
||||
func jump():
|
||||
@ -89,7 +87,7 @@ func set_rotation_y(y: float):
|
||||
func _on_reconciliation_timer_timeout() -> void:
|
||||
if multiplayer.is_server():
|
||||
_veryfy_position_and_rotation.rpc_id(owner_id)
|
||||
#update_position.rpc(shared_node.global_position)
|
||||
update_position.rpc(shared_node.global_transform.origin)
|
||||
$ReconciliationTimer.start()
|
||||
|
||||
@rpc("any_peer", "call_local", "reliable")
|
||||
|
@ -16,9 +16,6 @@ properties/2/replication_mode = 1
|
||||
properties/3/path = NodePath(".:jumping")
|
||||
properties/3/spawn = true
|
||||
properties/3/replication_mode = 2
|
||||
properties/4/path = NodePath("SharedNode:position")
|
||||
properties/4/spawn = true
|
||||
properties/4/replication_mode = 1
|
||||
|
||||
[node name="ServerNode" type="Node3D"]
|
||||
script = ExtResource("1_bau14")
|
||||
|
Loading…
Reference in New Issue
Block a user