square-poll-verticalStats

GC2 Stats Network Integration

Server-authoritative networking solution for Game Creator 2 Stats module, designed for competitive multiplayer environments where preventing stat manipulation/cheating is critical.

Overview

This module provides:

  • Server-Authoritative Stats - All stat/attribute modifications validated by server

  • Anti-Cheat Protection - Rate limiting, change validation, unauthorized modification rejection

  • Optimistic Updates - Responsive client-side feedback with server reconciliation

  • Bandwidth Efficiency - Delta sync, bitmask compression, minimal data structures

  • Transport Agnostic - Works with NGO, FishNet, Mirror, custom stacks, etc.

Architecture

┌──────────────────────────────────────────────────────────────────────┐
│                         CLIENT SIDE                                   │
├──────────────────────────────────────────────────────────────────────┤
│  GC2 Traits Component                                                 │
│       ↓ (stat change attempt)                                        │
│  NetworkStatsController                                               │
│       ↓ Request (optimistic update applied locally)                  │
│  NetworkStatsManager                                                  │
│       ↓ OnSendStatModifyRequest delegate                             │
│  [Your Transport Layer]                                              │
└──────────────────────────────────────────────────────────────────────┘

                              ↓ (Network)

┌──────────────────────────────────────────────────────────────────────┐
│                         SERVER SIDE                                   │
├──────────────────────────────────────────────────────────────────────┤
│  [Your Transport Layer]                                              │
│       ↓                                                              │
│  NetworkStatsManager.ReceiveStatModifyRequest()                      │
│       ↓ (validates request)                                          │
│  NetworkStatsController.ProcessStatModifyRequest()                   │
│       ↓ (applies to authoritative state)                             │
│  GC2 Traits Component                                                 │
│       ↓                                                              │
│  Broadcast response + state change to all clients                    │
└──────────────────────────────────────────────────────────────────────┘

Files

File
Purpose
Size (bytes)

NetworkStatsTypes.cs

Data structures for network serialization

~500

NetworkStatsController.cs

Per-character stat network management

~1000

NetworkStatsManager.cs

Global message routing singleton

~600

Setup

1. Add Manager to Scene

Add NetworkStatsManager component to a persistent GameObject in your scene:

2. Add Controller to Characters

Add NetworkStatsController to any character with GC2 Traits:

3. Wire Transport Delegates

Connect the manager's delegates to your networking solution:

Usage

Modifying Stats (Client-Side)

Instead of directly modifying GC2 stats:

Modifying Attributes (Health, Mana, etc.)

Status Effects

Listening for Changes

Network Data Efficiency

All structs are designed for minimal bandwidth:

Message Type
Approx. Size

StatModifyRequest

~20 bytes

StatModifyResponse

~6 bytes

AttributeModifyRequest

~20 bytes

AttributeChangeBroadcast

~20 bytes

StatusEffectRequest

~16 bytes

Delta sync (per changed stat)

~12 bytes

Delta Sync

The controller automatically tracks which stats/attributes changed and only sends deltas:

Anti-Cheat Features

Rate Limiting

Server Validation

The server can reject modifications for:

  • NotAuthorized - Client doesn't own target character

  • TargetNotFound - Invalid network ID

  • StatNotFound / AttributeNotFound - Invalid stat/attribute ID

  • InvalidValue - Value outside allowed range

  • RateLimitExceeded - Too many requests

  • Cooldown - Ability/effect on cooldown

Custom Validation

Optimistic Updates

For responsive gameplay, clients can apply changes immediately:

Flow:

  1. Client sends request

  2. Client applies change locally (optimistic)

  3. Server validates and responds

  4. If rejected → rollback to original value

  5. If approved → keep current value

Integration with Combat

The Stats module integrates with the Melee and Shooter combat modules:

Debugging

Enable logging for troubleshooting:

Requirements

  • Unity 2021.3+

  • Game Creator 2 Stats module

  • Compatible networking solution (NGO, FishNet, Mirror, or custom adapter)

Module Dependencies

Last updated