gunShooter

Server-authoritative shooter combat networking for Game Creator 2.

Overview

This module provides network-aware shooter combat for GC2, enabling server-authoritative shot and hit validation with lag compensation. It integrates seamlessly with the base GC2 Network Integration and supports raycast, projectile, and all GC2 shot types.

Requirements

  • Game Creator 2 Core

  • Game Creator 2 Shooter Module

  • GC2 Network Integration (base module)

  • A configured transport adapter (NGO/FishNet/Mirror/custom)

Installation

  1. Import the GC2 Network Integration base module

  2. Import this GC2 Shooter Network module

  3. The module will auto-detect GC2 Shooter via the GC2_SHOOTER define symbol

Architecture

Network Flow

Two-Phase Validation

Unlike melee, shooter combat uses two-phase validation:

  1. Shot Validation: When trigger is pulled

    • Validates: ammo, weapon state, cooldown, position

    • Results in: muzzle flash, tracer, sound

  2. Hit Validation: When shot hits something

    • Validates: hit position, target state, obstruction

    • Results in: damage, impact effects, reactions

This allows for accurate projectile-based weapons where the hit happens after the shot.

Components

NetworkShooterManager

Global singleton that coordinates all shooter networking.

Setup:

NetworkShooterController

Per-character component that handles shot and hit interception.

Properties:

  • Optimistic Shot Effects: Show tracer/muzzle flash before server confirmation

  • Optimistic Hit Effects: Show impact effects before server confirmation

  • Weapon State Sync Interval: How often to sync ammo/reload/jam state

  • Aim State Sync Interval: How often to sync aim direction

ConditionNetworkShooterHit (Visual Scripting)

A GC2 Condition that intercepts hits in the ShooterWeapon's "Can Hit" conditions.

Usage:

  1. Open your ShooterWeapon asset

  2. Find the "Can Hit" conditions section

  3. Add the "Network Shooter Hit" condition

Setup Guide

Step 1: Scene Setup

  1. Add NetworkShooterManager to your scene

  2. Configure the network delegates

Step 2: Character Setup

For each networked character with shooter weapons:

  1. Add NetworkCharacter component

    • Set Combat Mode = Disabled

  2. Add NetworkShooterController component

    • Configure optimistic effects preferences

Step 3: Weapon Setup

For each ShooterWeapon that should use network hit validation:

  1. Open the ShooterWeapon ScriptableObject

  2. In "Can Hit" conditions, add Network Shooter Hit condition

Step 4: Network Transport

Connect the manager to your transport adapter. Optional NGO example: This sample follows NGO 2.10 unified RPC API ([Rpc], RpcParams, RpcTarget).

Data Types

NetworkShotRequest (~40 bytes)

Sent from client to server when a shot is fired.

Field
Type
Description

RequestId

ushort

Unique ID for response matching

ClientTimestamp

float

When shot was fired

ShooterNetworkId

uint

Shooter's network ID

MuzzlePosition

Vector3

Muzzle position at fire time

ShotDirection

Vector3

Direction with spread applied

WeaponHash

int

Hash of weapon used

SightHash

int

Hash of sight used

ChargeRatio

float

For charged weapons (0-1)

ProjectileIndex

byte

Index for multi-projectile

TotalProjectiles

byte

Total projectiles in shot

NetworkShooterHitRequest (~36 bytes)

Sent when a shot hits something.

Field
Type
Description

RequestId

ushort

Unique ID

ClientTimestamp

float

When hit detected

ShooterNetworkId

uint

Who fired

TargetNetworkId

uint

Who was hit (0 for environment)

HitPoint

Vector3

World position of hit

HitNormal

Vector3

Surface normal

Distance

float

Distance from muzzle

WeaponHash

int

Weapon used

PierceIndex

byte

Pierce order (0 = first)

IsCharacterHit

bool

Hit a character vs environment

NetworkShotBroadcast (~32 bytes)

Broadcast when shot is confirmed.

Field
Type
Description

ShooterNetworkId

uint

Who fired

MuzzlePosition

Vector3

Muzzle position

ShotDirection

Vector3

Shot direction

WeaponHash

int

For effects lookup

SightHash

int

For effects lookup

HitPoint

Vector3

Final hit point (for tracer)

DidHit

bool

Whether it hit something

NetworkShooterHitBroadcast (~28 bytes)

Broadcast when hit is confirmed.

Field
Type
Description

ShooterNetworkId

uint

Who fired

TargetNetworkId

uint

Who was hit

HitPoint

Vector3

Hit position

HitNormal

Vector3

Hit normal

WeaponHash

int

For effects

BlockResult

byte

Block/parry result

MaterialHash

int

For impact sound

NetworkWeaponState (~12 bytes)

Synced periodically for weapon status.

Field
Type
Description

WeaponHash

int

Equipped weapon

SightHash

int

Current sight

AmmoInMagazine

ushort

Current ammo

StateFlags

byte

Bitflags for state

State Flags:

  • 0x01: Is Reloading

  • 0x02: Is Jammed

  • 0x04: Is Aiming

  • 0x08: Is Shooting

  • 0x10: Is Charging

Rejection Reasons

Shot Rejection

Enum
Description

ShooterNotFound

Shooter doesn't exist on server

WeaponNotEquipped

Weapon not equipped

NoAmmo

Out of ammunition

WeaponJammed

Weapon is jammed

CooldownActive

Fire rate limit

InvalidPosition

Suspicious muzzle position

InvalidDirection

Suspicious shot direction

TimestampTooOld

Request too far in past

RateLimitExceeded

Firing too fast

CheatSuspected

Anti-cheat triggered

Hit Rejection

Enum
Description

ShotNotValidated

Associated shot was rejected

TargetNotFound

Target doesn't exist

OutOfRange

Hit too far from shot

ObstructionDetected

Something blocking shot

TargetInvincible

Target has invincibility

TargetDodged

Target was dodging

AlreadyHit

Duplicate hit detection

TimestampTooOld

Too far in past

CheatSuspected

Anti-cheat triggered

Weapon State Synchronization

The controller automatically syncs weapon state (ammo, reload, jam) at configurable intervals:

Subscribe to state changes:

Advanced: Custom Shot Types

If you create custom TShot implementations, integrate network awareness:

Troubleshooting

Shots not registering on server

  1. Check NetworkShooterManager is in scene

  2. Verify network delegates are connected

  3. Check ammo sync - server may think you have no ammo

Tracer not showing on remote clients

  1. Verify BroadcastShotToAllClients is connected

  2. Check remote clients are receiving broadcasts

  3. Ensure weapon effects are configured

Hit effects delayed

  1. Check optimistic effects setting

  2. Verify network latency

  3. Consider enabling optimistic for better feel

Ammo desynced between client/server

  1. Check WeaponStateSyncInterval setting

  2. Ensure server is authoritative for ammo

  3. Use OnWeaponStateChanged event to sync

Transport Agnostic Design

Like the Melee module, this is completely transport-agnostic:

Transport
Implementation

Netcode for GameObjects

[Rpc(SendTo.*)] + RpcTarget.Single(...)

FishNet

[ServerRpc], [ObserversRpc]

Mirror

[Command], [ClientRpc]

Photon Fusion

[Rpc] attributes

You implement the bridge layer; we handle the combat logic.

Last updated