본문으로 건너뛰기
cccskills
무료GitHub에 공개

godot-multiplayer

Add networked multiplayer to Godot 4.7 games with server and client connections, remote function calls, node ownership, and synchronized game state. Includes patterns for validating player requests on the server and replicating scenes across connected players.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

원문원문 설명 보기

Build networked games with Godot 4.7 high-level multiplayer: set up an ENetMultiplayerPeer server/client, define RPCs with the @rpc annotation (call via rpc()/rpc_id()), set per-node multiplayer authority, and replicate state with MultiplayerSpawner and MultiplayerSynchronizer. Use when adding multiplayer/networking to a Godot project, writing @rpc functions, or syncing player/world state across peers.

실행 점수 미검증

설치 방법 보기

이럴 때 유용합니다

  • Adding online multiplayer to a Godot game
  • Implementing remote function calls
  • Synchronizing player and world state
  • Validating player requests on the server

포함된 파일(2)

  • SKILL.md6.3 KB
  • references/replication-and-rpc.md4.5 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

Godot Multiplayer (4.x high-level)

Connect peers, call functions remotely with @rpc, assign authority, and replicate state with MultiplayerSpawner/MultiplayerSynchronizer. Targets Godot 4.7 (ENet). Treat all client input as untrusted; keep the server authoritative.

When to use

  • Use when adding networked multiplayer: hosting/joining over ENet, calling RPCs, assigning per-node authority, or auto-spawning/syncing nodes across peers.

When not to use: local split-screen (no networking); raw TCP/UDP/WebSocket protocol work (low-level PacketPeer); HTTP requests. For save/persistence → save-systems.

Core workflow

  1. Create a peer (ENetMultiplayerPeer), call create_server(port, max) or create_client(ip, port), and assign it to multiplayer.multiplayer_peer. The server's unique ID is always 1; clients get random positive IDs.
  2. Handle connection signals on multiplayer: peer_connected(id), peer_disconnected(id), connected_to_server, connection_failed, server_disconnected.
  3. Define RPCs with @rpc(...). Call them on a Callable via rpc() (all peers) or rpc_id(peer_id) (one peer). Inside, multiplayer.get_remote_sender_id() tells you who sent it.
  4. Keep RPC signatures identical on every peer that runs the script — Godot checksums all @rpc methods in a script; mismatches break silently.
  5. Assign authority per node with set_multiplayer_authority(id); gate input/RPCs by is_multiplayer_authority().
  6. Replicate state with MultiplayerSpawner (auto-instances scenes on clients) and MultiplayerSynchronizer (auto-syncs selected properties).
  7. Validate on the server. Don't trust client-reported positions/results.

Patterns

1. Host or join (ENet)

const PORT := 7000
const MAX_PLAYERS := 8

func host() -> void:
    var peer := ENetMultiplayerPeer.new()
    var err := peer.create_server(PORT, MAX_PLAYERS)
    if err != OK:
        push_error("Cannot host: %s" % err); return
    multiplayer.multiplayer_peer = peer
    multiplayer.peer_connected.connect(_on_peer_connected)

func join(ip := "127.0.0.1") -> void:
    var peer := ENetMultiplayerPeer.new()
    peer.create_client(ip, PORT)
    multiplayer.multiplayer_peer = peer
    multiplayer.connected_to_server.connect(func(): print("connected"))

func leave() -> void:
    multiplayer.multiplayer_peer = OfflineMultiplayerPeer.new()

2. RPCs: client sends input to the server (any_peer, call_local)

func _unhandled_input(event: InputEvent) -> void:
    if event.is_action_pressed("fire") and is_multiplayer_authority():
        request_fire.rpc_id(1)          # send only to the server (id 1)

# Clients may call this; it runs on the server (and locally if server is a player).
@rpc("any_peer", "call_local", "reliable")
func request_fire() -> void:
    var sender := multiplayer.get_remote_sender_id()
    if not _can_fire(sender):           # server-side validation
        return
    spawn_projectile.rpc(sender)        # tell everyone to spawn it

@rpc("authority", "call_local", "reliable")
func spawn_projectile(owner_id: int) -> void:
    _do_spawn(owner_id)

3. Per-node authority (each player controls their own avatar)

extends CharacterBody2D

func _ready() -> void:
    # The node name is the owning peer's id; that peer is the authority.
    set_multiplayer_authority(name.to_int())

func _physics_process(delta: float) -> void:
    if not is_multiplayer_authority():
        return                          # only the owner reads input & moves
    velocity = Input.get_vector("left", "right", "up", "down") * 200.0
    move_and_slide()

4. MultiplayerSynchronizer config (editor + replication)

# Add a MultiplayerSynchronizer child; in its Replication editor add the properties to
# sync (e.g. position, velocity). Set "Sync"/"Spawn" flags per property. From code you
# can scope visibility:
@onready var sync: MultiplayerSynchronizer = $MultiplayerSynchronizer

func _ready() -> void:
    # Only replicate this node to a specific peer (e.g. private info).
    sync.set_visibility_for(target_peer_id, true)

Pitfalls

  • RPC signature checksum. Every @rpc method in a script must exist with the same declaration on both client and server builds — even unused ones. A mismatch causes errors that may point at the wrong function. Argument names/count are not checked, but the set of RPCs and their annotations are.
  • Default @rpc is "authority". Clients calling it are ignored unless you set "any_peer". Use "call_local" so the host (also a player) runs it too.
  • NodePaths must match across peers. RPC routing uses the node's path/name; spawn nodes with identical names on all peers (use MultiplayerSpawner or add_child(node, true) for readable, deterministic names).
  • Trusting the client. Never let clients set authoritative state (health, position, hits) directly. Send intent, validate on the server, then broadcast results.
  • RPC on non-Node classes fails. @rpc methods must be on Node-derived classes, not plain Resource/RefCounted.
  • RPCs don't serialize Objects/Callables. Pass plain data (ints, strings, arrays, dictionaries, PackedArrays).
  • Forgetting to reset the peer. To disconnect cleanly, set multiplayer.multiplayer_peer = OfflineMultiplayerPeer.new().
  • Android needs INTERNET permission in the export preset or all networking is blocked.

References

  • For MultiplayerSpawner setup, transfer modes/channels, SceneMultiplayer authentication (auth_callback/complete_auth), a lobby skeleton, and dedicated-server export notes, read references/replication-and-rpc.md.

Related skills

  • godot-nodes-scenes — instancing the scenes that get spawned/synced.
  • godot-signals-groups — connection signals and event flow.
  • godot-export — exporting a headless dedicated server build.

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Implement reusable decision systems for game characters using behavior trees, which organize conditional actions, and Utility AI, which scores available choices. Build either approach or combine them to control patrols, combat, targeting, and needs-based behavior.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Build a reusable behavior tree runtime
  • Choose attacks or targets using action scores
  • Combine patrol and combat trees with Utility AI
gamedev-skills/awesome-gamedev-agent-skills3.6천2026년 10월 23일 업데이트

Design game audio with grouped volume controls, music that responds to gameplay, and varied sound effects. Plan how music lowers during dialogue and how events follow the beat, using principles that can be adapted to different game engines.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Plan grouped volume controls for music, effects, and dialogue
  • Lower background music while dialogue plays
  • Change music layers or segments with gameplay intensity
gamedev-skills/awesome-gamedev-agent-skills3.6천2026년 10월 23일 업데이트

bevy-ecs

무료

Build and debug Rust games in Bevy using ECS, a way to separate game data from behavior. Organize apps and plugins, query entities, control execution order, and fix conflicting data access or frame-dependent movement.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Organizing a Bevy app with plugins
  • Defining components and shared resources
  • Fixing conflicting queries and execution order
gamedev-skills/awesome-gamedev-agent-skills3.6천2026년 10월 23일 업데이트

Build and tune game cameras for smooth 2D following and 3D viewing. Covers motion smoothing, look-ahead, level boundaries, wall avoidance, and framing multiple targets, with techniques that apply across engines.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Smooth player-follow cameras in 2D games
  • Keep the camera view within level boundaries
  • Prevent third-person cameras from clipping through walls
gamedev-skills/awesome-gamedev-agent-skills3.6천2026년 10월 23일 업데이트

card-game

무료

Design the core rules of a card game, including decks, hands, discards, drawing, shuffling, turns, and resource costs. Represent card effects as data and define their resolution order so card movement and gameplay outcomes follow explicit rules.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Building a deckbuilder or trading card game
  • Implementing draws and discard reshuffling
  • Defining turn phases and card costs
gamedev-skills/awesome-gamedev-agent-skills3.6천2026년 10월 23일 업데이트

Plan and prepare consistent game artwork, from sprites and backgrounds to UI icons and 3D briefs. Organize asset requirements, generate or source related visuals, standardize files, and check their appearance and technical fit inside the game.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Create sprites and backgrounds with a consistent visual style
  • Check asset dimensions, transparency, and tile seams
  • Track asset sources and licenses before release
gamedev-skills/awesome-gamedev-agent-skills3.6천2026년 10월 23일 업데이트

gamedev-skills의 스킬 모두 보기

이 스킬의 문제 신고