feat: integrate ChaffGames FPS template as local player controller
Replaces the overhead box-mesh view with a full FPS character: - mouse look, WASD movement, jump (Space), crouch (C), sprint (Shift), lean (Q/E) - 6 weapons (LMB shoot, R reload, scroll switch, F melee, G drop) - Crosshair HUD, ammo counter, sprint bar - Client sends position to server at 20Hz for multiplayer visibility - Server broadcasts positions to all peers - Remote players shown as boxes (placeholder) source: https://godotengine.org/asset-library/asset/2652 (MIT license)
This commit is contained in:
@@ -215,3 +215,23 @@ func _physics_process(delta: float) -> void:
|
||||
|
||||
# Future: authoritative physics tick, state broadcast, etc.
|
||||
pass
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Client position replication (receives from FPS character clients)
|
||||
# ---------------------------------------------------------------------------
|
||||
@rpc("unreliable", "any_peer")
|
||||
func _send_position(pos: Vector3) -> void:
|
||||
# Called by remote clients to update their position on the server.
|
||||
# Broadcast to all other peers so they see the player move.
|
||||
var peer_id: int = multiplayer.get_remote_sender_id()
|
||||
if peer_id in players:
|
||||
players[peer_id].position = pos
|
||||
# Re-broadcast to all other peers
|
||||
_replicate_position.rpc(pos, peer_id)
|
||||
|
||||
@rpc("unreliable", "authority")
|
||||
func _replicate_position(pos: Vector3, exclude_peer: int) -> void:
|
||||
# All clients receive this and update the specific player's position.
|
||||
# We need to find which remote player this belongs to by excluding our own.
|
||||
# For now, the non-authority clients will need to filter — handled in client_main.gd
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user