Full SDK for JavaScript support in the UPBGE Game Engine, fully independent of the UPBGE core.
This SDK provides JavaScript development support in UPBGE, including:
- Interactive Console: JavaScript console for quick code testing
- External Editor Integration: Quick open of the SDK/project in VS Code, Cursor, or a custom editor
- Type Definitions: Type definitions in
types/for optional use in editors that support JSDoc /.d.ts - Game Engine Integration: Integration with JavaScript controllers in the game engine
Plug-and-Play: Download the official upbge-javascript-sdk-X.X.X.zip package, which includes all required binaries. See the "Option 2" section below.
If you are developing or contributing to the SDK, you will need to install dependencies manually:
- Directory structure: Run
python scripts/setup_sdk.py - Node.js: Run
python scripts/download_dependencies.pyor install manually (seeINSTALL_DEPENDENCIES.mdif needed)
- Clone or download this repository
- Run
python scripts/setup_sdk.pyto create the directory structure - Install dependencies (Node.js) — see
INSTALL_DEPENDENCIES.mdonly if you want to install extra tools - In Blender, go to Edit → Preferences → Add-ons
- Click Install... and select the
upbge-javascriptfolder - Enable the "UPBGE JavaScript SDK" add-on
- Configure the SDK path in the add-on preferences
- Download the official package
upbge-javascript-sdk-X.X.X.zip(includes all binaries) - In Blender/UPBGE, go to Edit → Preferences → Add-ons
- Click Install... and select the downloaded ZIP file
- Enable the "UPBGE JavaScript SDK" add-on
- Done! The SDK is ready (plug-and-play, no extra dependencies to install)
Note for developers: To build a distribution package with all binaries included, run:
python scripts/build_package.pyThis will create a ZIP file ready for distribution, including the add-on and the Node.js runtime.
For a quick setup guide, see SETUP.md.
- Open Edit → Preferences → Add-ons
- Select "UPBGE Node.js SDK"
- Set SDK Path to the SDK directory
- The SDK will load automatically
The SDK can be configured in three ways (in order of priority):
- Environment variable:
BGE_JAVASCRIPT_SDK(absolute path) - Local SDK:
./bge_js_sdk/relative to the .blend file - Preferences: Path set in the add-on preferences
By default, each time a JavaScript controller runs, the add-on starts a new Node.js process, runs your script, and then exits. For games with many controllers or heavy logic, that can add overhead.
You can enable Use Persistent Worker in the add-on preferences (Edit → Preferences → Add-ons → UPBGE Node.js SDK → Advanced Settings). When enabled:
- A single Node.js process is kept running for the whole game session.
- Scripts are sent to this process over stdin instead of spawning a new process per frame.
- This reduces the cost of starting Node.js repeatedly and can improve performance when many controllers run every frame.
The option is off by default so that the default behavior stays simple (one process per run). Turn it on if you notice lag or high CPU from frequent controller execution.
upbge-javascript/
├── __init__.py # Main add-on
├── python/ # Python modules
│ ├── console/ # JavaScript console
│ ├── runtime/ # JavaScript runtime (Node.js wrapper)
│ └── game_engine/ # Game engine integration
├── runtime/ # Node.js executables
│ ├── windows/
│ ├── linux/
│ └── macos/
├── lib/ # (Optional) additional libraries and tools
└── types/ # Type definitions for use in editors
└── bge.d.ts
- Open the Console in Blender (Window → Toggle System Console or Shift+F4)
- In the console language menu, select JavaScript
- Type code and press Enter to run it
JavaScript example:
>>> console.log("Hello, UPBGE!")
Hello, UPBGE!
>>> let x = 10 + 20
30- In the Logic Editor, add a JavaScript Controller
- Select the controller and configure a JavaScript script using the add-on panel
- The code runs in the game engine via Node.js
Controller example:
// Move object forward
let obj = bge.logic.getCurrentObject();
if (obj) {
obj.position[2] += 0.1;
}The types/ directory contains optional .d.ts files for autocomplete in editors that support JSDoc/type definitions. They are not used by the add-on at runtime.
To use TypeScript (or get full type checking and IntelliSense for the BGE API in JavaScript), include the SDK type definitions in your project. Add the files under types/ to your tsconfig.json so the compiler and editor pick up the bge namespace and related types.
Option A — SDK as part of your project
If the SDK lives inside your project (e.g. in a subfolder), add the types folder to include:
{
"compilerOptions": {
"target": "ES2020",
"module": "commonjs",
"strict": true
},
"include": [
"src/**/*",
"path/to/upbge-nodejs-sdk/types/**/*.d.ts"
]
}Option B — SDK installed elsewhere
If the SDK is in another directory (e.g. add-on path), use typeRoots or a direct path in include so your tsconfig.json points at the SDK types:
{
"compilerOptions": {
"target": "ES2020",
"module": "commonjs",
"strict": true,
"typeRoots": ["./node_modules/@types", "C:/path/to/sdk/types"]
},
"include": ["src/**/*"]
}Or reference the definition files explicitly:
{
"include": ["src/**/*", "C:/path/to/sdk/types/index.d.ts"]
}Replace C:/path/to/sdk with the actual path to your SDK (or use a relative path). After that, types like bge.logic, bge.constraints, GameObject, and Scene will be available for autocomplete and type checking. The game engine still runs the compiled JavaScript (or the add-on’s JS runtime); the .d.ts files are only for development.
- UPBGE: Version 5.0 or later
- Node.js: Included in the SDK (no external installation required)
python/console/: JavaScript consolepython/runtime/: Node.js wrapper for executionpython/game_engine/: Controller integration
Contributions are welcome! Please:
- Fork the repository
- Create a branch for your feature
- Commit your changes
- Open a Pull Request
GPL-2.0-or-later (same license as UPBGE)
- The SDK is fully independent of the UPBGE core
- Node.js is included in the SDK
- The SDK can be updated independently of UPBGE
- Support for multiple SDK versions per project
