push ze latest and greatest

This commit is contained in:
2025-12-30 16:22:06 +01:00
parent def119e21d
commit 1725c615ce
9 changed files with 1698 additions and 24 deletions

View File

@@ -59,7 +59,7 @@ var accelerationZ = -330.0 # Gravity
locked_grab_direction = Vector2.ZERO # Clear locked direction when releasing
var is_player = true
@export var direction_vector = Vector2(0, 0)
var direction_vector = Vector2(0, 0) # NOT exported - each player handles their own input locally
const ANIMATIONS = {
"IDLE": {
@@ -577,21 +577,18 @@ func _apply_movement_from_input(_delta: float) -> void:
locked_grab_direction = Vector2.ZERO
is_grabbing = false
var pot = a.get_parent()
var pot = a.get_parent()
if multiplayer.is_server():
# Server can interact directly
held_entity = pot
held_entity_path = str(pot.get_path())
pot.lift(self)
current_animation = "LIFT"
if multiplayer.is_server():
# Server can interact directly
held_entity = pot
#held_entity_path = str(pot.get_path())
#pot.lift(self)
#current_animation = "LIFT"
else:
# Client uses RPC to request from server
MultiplayerManager.request_lift_pot.rpc_id(1, pot.get_path(), multiplayer.get_unique_id())
else:
# Client uses RPC to request from server
# DON'T set animation or held_entity here - server will sync it
MultiplayerManager.request_lift_pot.rpc_id(1, pot.get_path(), multiplayer.get_unique_id())
break # only allow 1 at a time :)
pass
pass
@@ -602,7 +599,9 @@ func _apply_movement_from_input(_delta: float) -> void:
is_grabbing = false
if held_entity == null:
is_lifting = false
elif held_entity != null and is_lifting == false:
# CRITICAL: Only run auto-throw/put-down logic for the authority (the player controlling this character)
# Otherwise, when held_entity_path syncs, ALL clients will run this and set animations
elif held_entity != null and is_lifting == false and get_multiplayer_authority() == multiplayer.get_unique_id():
if velocity.x != 0 or velocity.y != 0:
if multiplayer.is_server():
held_entity.throw(last_direction)
@@ -1071,6 +1070,12 @@ func set_grabbed_entity_path_rpc(entity_path: String):
# This ensures locked_grab_direction is set correctly via the setter
grabbed_entity_path = entity_path
@rpc("authority", "reliable")
func sync_spawn_position(spawn_pos: Vector2):
# Server tells this client where to spawn
position = spawn_pos
print("Client ", multiplayer.get_unique_id(), " received spawn position: ", spawn_pos)
@rpc("call_local")
func lift():

View File

@@ -73,18 +73,15 @@ properties/9/replication_mode = 2
properties/10/path = NodePath(".:collision_layer")
properties/10/spawn = true
properties/10/replication_mode = 2
properties/11/path = NodePath(".:direction_vector")
properties/11/path = NodePath(".:held_entity_path")
properties/11/spawn = true
properties/11/replication_mode = 2
properties/12/path = NodePath(".:held_entity_path")
properties/12/path = NodePath(".:grabbed_entity_path")
properties/12/spawn = true
properties/12/replication_mode = 2
properties/13/path = NodePath(".:grabbed_entity_path")
properties/13/path = NodePath(".:current_direction")
properties/13/spawn = true
properties/13/replication_mode = 2
properties/14/path = NodePath(".:current_direction")
properties/14/spawn = true
properties/14/replication_mode = 2
[sub_resource type="Gradient" id="Gradient_hsjxb"]
offsets = PackedFloat32Array(0.847255, 0.861575)