Reading time: ~15 minutes
CORP (Component-Oriented Replicated Programming) is a powerful game development framework for Roblox built with roblox-ts. It provides a Unity-like ECS architecture with GameObjects and Components, along with a built-in networking system inspired by Unityโs Netcode for GameObjects.
๐ Quick Start
Get up and running in minutes:
-
Install Required Tools
-
Clone the CORP Template
git clone https://github.com/MonoliskSoftware/CORP-TEMPLATE
cd CORP-TEMPLATE
git submodule update --init --recursive
npm install
-
Configure your game
Update
GAMEPACKS/MYGAME/metadata.ts:
const metadata: Gamepacks.Config.Metadata = {
name: "MyGameName", // Change this
// ... rest of config
};
Update GAMECONFIG/gameinfo.ts:
const gameinfo: Unreal.Gameinfo = {
rootPack: "MyGameName", // Must match metadata name
authority: Unreal.Authority.SERVER
};
-
Create your first component
In
GAMEPACKS/MYGAME/src/:
import { Behavior } from "CORP/shared/componentization/behavior";
export class HelloWorld extends Behavior {
public onStart(): void {
print("Hello, CORP!");
}
public willRemove(): void {}
protected getSourceScript(): ModuleScript {
return script as ModuleScript;
}
}
-
Export your component
In
GAMEPACKS/MYGAME/exports/components.ts:
const components: Config.Components = {
mappings: {
"hello_world": HelloWorld
}
};
-
Start Development
Terminal 1 - Start Rojo:
rojo serve default.project.json
Terminal 2 - Watch TypeScript:
Connect Roblox Studio to Rojo and press Play!
๐ Full Getting Started Guide โ | Unreal System Guide โ
๐ Documentation
Core Documentation
| Guide | Description |
| Getting Started | Installation, setup, and your first component |
| Roblox Studio | Essential Roblox concepts for CORP developers |
| Core Concepts | GameObjects, Components, Behaviors, and lifecycle |
| Networking | NetworkObjects, NetworkBehaviors, NetworkedVariables, and RPCs |
| Scene Management | Creating, loading, and managing game scenes |
| Unreal System | Gamepacks, authority models, and modular game organization |
| Macros | Instance transformation and procedural generation |
| ScriptableObjects | Data assets and configuration management |
| Decorators | Using @SerializeField, @RequiresComponent, @RPC, and more |
| Advanced Topics | Spawn management, observables, optimization, and patterns |
Reference & Examples
| Guide | Description |
| API Reference | Complete API documentation for all classes and methods |
| Examples | Practical examples and tutorials for common game features |
โจ Features
๐ฎ Unity-Style Architecture
Familiar GameObject and Component patterns for organized game development.
const player = new GameObject("Player");
player.addComponent(PlayerController);
player.addComponent(HealthSystem, { maxHealth: 100 });
๐ Built-in Networking
Automatic replication with NetworkObjects and NetworkBehaviors.
@RequiresComponent(NetworkObject)
export class PlayerSync extends NetworkBehavior {
public readonly position = new NetworkedVariable<Vector3>(Vector3.zero);
}
๐ก Type-Safe RPCs
Remote Procedure Calls with flexible configuration.
@RPC.Method({
endpoints: [RPC.Endpoint.CLIENT_TO_SERVER],
accessPolicy: RPC.AccessPolicy.OWNER
})
public attack(targetId: string): void {
// Server validates and processes
}
๐ Automatic State Sync
NetworkedVariables, Lists, Maps, and Sets synchronize automatically.
public readonly health = new NetworkedVariable<number>(100);
public readonly inventory = new NetworkedList<string>();
public readonly scores = new NetworkedMap<string, number>();
๐ฌ Scene Management
Load and manage game scenes with serialization support.
const scene: SceneSerialization.SceneDescription = {
children: [
{
name: "Player",
components: [
{ path: ["src", "components", "PlayerController"], data: {} }
],
children: []
}
]
};
๐ฏ Component Lifecycle
Predictable initialization and cleanup with lifecycle hooks.
export class MyComponent extends Behavior {
public willStart(): void { /* Pre-init */ }
public onStart(): void { /* Initialize */ }
public onPropertiesApplied(): void { /* React to config */ }
public willRemove(): void { /* Cleanup */ }
}
๐ Learning Path
๐ข Beginner
- Getting Started - Step-by-step tutorial to create your first game
- Core Concepts - Understanding GameObjects and Components
- Unreal System - Understanding Gamepacks and project structure
- Scene Management - Advanced scene loading and organization
- Macros - Transform instances into GameObjects procedurally
- ScriptableObjects - Create reusable data assets
- Decorators - Use component decorators effectively
- Examples - Build player controllers, health systems, and weapons
๐ด Advanced
- Networking - Create multiplayer experiences
- Advanced Topics - Master advanced patterns and optimization
- API Reference - Complete API reference
๐ Common Use Cases
See Examples for complete tutorials on:
- Simple Player Controller - Character movement and input
- Health System - Networked health with damage and respawn
- Weapon System - Shooting mechanics with server validation
- Enemy AI - Pathfinding and target tracking
- Inventory System - Item management and UI
- Game Manager - Match flow and win conditions
๐ Key Concepts
GameObjects
Entities in your game world that contain Components.
const enemy = new GameObject("Enemy");
enemy.setParent(parentObject);
Components
Define behavior and data for GameObjects.
export class MyComponent extends Component {
public onStart(): void { /* Initialize */ }
public willRemove(): void { /* Cleanup */ }
}
Behaviors
Components with serialization support.
export class MyBehavior extends Behavior {
@SerializeField
public configValue: number = 10;
}
NetworkObjects
Make GameObjects replicate across the network.
const netObj = player.addComponent(NetworkObject);
netObj.spawn(); // Server only
NetworkBehaviors
Components that replicate their state.
@RequiresComponent(NetworkObject)
export class MyNetworkBehavior extends NetworkBehavior {
public readonly syncedValue = new NetworkedVariable<number>(0);
}
๐ ๏ธ Architecture Overview
CORP Framework
โโโ Core
โ โโโ GameObject - Entity container
โ โโโ Component - Base behavior class
โ โโโ Behavior - Serializable component
โ
โโโ Networking
โ โโโ NetworkObject - Replication root
โ โโโ NetworkBehavior - Networked component
โ โโโ NetworkedVariable - Synced state
โ โโโ RPC - Remote procedure calls
โ
โโโ Scene Management
โ โโโ SceneManager - Scene lifecycle
โ โโโ Scene - Scene container
โ โโโ SceneSerialization - Scene format
โ
โโโ Utilities
โโโ Signal - Event system
โโโ Collector - Resource cleanup
โโโ Identification - ID generation
๐ฏ Best Practices
- Use
Behavior for most components (serialization support)
- Initialize in
onStart(), not the constructor
- Use
@RequiresComponent for dependencies
- Let server make authoritative decisions
- Use batched replication when possible
- Clean up resources with
collector
โ Avoid
- Accessing components in constructor
- Modifying NetworkedVariables on client
- Using instantaneous replication for frequent updates
- Forgetting to call
super() in constructors
- Serializing runtime state (use configuration instead)
๐ก Quick Reference
Common Imports
// Core
import { CORP } from "CORP/shared/CORP";
import { GameObject } from "CORP/shared/componentization/game-object";
import { Behavior } from "CORP/shared/componentization/behavior";
// Networking
import { NetworkObject } from "CORP/shared/networking/network-object";
import { NetworkBehavior } from "CORP/shared/networking/network-behavior";
import { NetworkedVariable } from "CORP/shared/observables/networked-observables/networked-variable";
import { RPC } from "CORP/shared/networking/RPC";
// Decorators
import { SerializeField } from "CORP/shared/serialization/serialize-field";
import RequiresComponent from "CORP/shared/componentization/decorators/requires-component";
Component Template
import { Behavior } from "CORP/shared/componentization/behavior";
import { GameObject } from "CORP/shared/componentization/game-object";
import { SerializeField } from "CORP/shared/serialization/serialize-field";
export class MyComponent extends Behavior {
@SerializeField
public configValue: number = 10;
public constructor(gameObject: GameObject) {
super(gameObject);
}
public onStart(): void {
// Initialize
}
public willRemove(): void {
// Cleanup
}
protected getSourceScript(): ModuleScript {
return script as ModuleScript;
}
}
NetworkBehavior Template
import { NetworkBehavior } from "CORP/shared/networking/network-behavior";
import { NetworkObject } from "CORP/shared/networking/network-object";
import RequiresComponent from "CORP/shared/componentization/decorators/requires-component";
import { NetworkedVariable } from "CORP/shared/observables/networked-observables/networked-variable";
import { RPC } from "CORP/shared/networking/RPC";
@RequiresComponent(NetworkObject)
export class MyNetworkBehavior extends NetworkBehavior {
public readonly syncedValue = new NetworkedVariable<number>(0);
public onStart(): void {
// Initialize
}
@RPC.Method({
endpoints: [RPC.Endpoint.CLIENT_TO_SERVER],
accessPolicy: RPC.AccessPolicy.OWNER
})
public myRPC(): void {
// Server logic
}
public willRemove(): void {
// Cleanup
}
protected getSourceScript(): ModuleScript {
return script as ModuleScript;
}
}
๐ค Contributing
We welcome contributions! Check out the main repository for contribution guidelines.
๐ License
See the main repository for license information.
๐ Links
Ready to build amazing games with CORP! ๐
Start with the Getting Started Tutorial or explore Examples to see CORP in action.