This project is a sample of the Open Kinematic Character Controller for the Godot game engine. A Kinematic Character Controller (KCC) provides a way to control a character avatar as a kinematic object that will interact with the environment.
OpenKCC is an open source project hosted at https://github.com/nicholas-maltbie/Godot-OpenKCC.
This is an open source project licensed under a MIT License. Feel free to use a build of the project for your own work. If you see an error in the project or have any suggestions, write an issue or make a pull request, I'll happily include any suggestions or ideas into the project.
You can see a demo of the project running here: https://openkcc.nickmaltbie.com/.
The project hosted on the website is up to date with the most recent version on
the main
branch of this github repo and is automatically
deployed with each update to the codebase.
Install Godot v4.2.2-stable, then make sure to setup the build tools for the project. Setup guide for required tools by platform: Building from Source
Using the GDExtensions to develop with C++, see GDExtension C++ example for details.
Note install godot via Scoop for windows, see Command Line Tutorial from Godot's docs for more details.
# Setup godot-cpp
git -C godot-cpp submodule update --init
# Setup build platform tools for windows and web environment
scons --directory godot-cpp -j4
# Build openkcc libraries for your development platform.
scons -j4
scons target=editor -j4
# Note, I ran into some issues with the build and multi threading and
# some of the build dependencies attaching a flag such as -j1 at the end
# seemed to resolve those errors.
Build project export using godot via cli or via the editor.
See setup guide Compiling for Windows with godot.
# Build libraries for openkcc
scons --directory godot-cpp platform=windows -j4
scons platform=windows target=template_release -j4
# Optional: Download redit tool
$url = "https://github.com/electron/rcedit/releases/download/v1.1.1/rcedit-x64.exe"
$out = "external\rcedit-x64.exe"
mkdir -p external
Invoke-WebRequest -Uri $url -OutFile $out
# Export debug windows-desktop build
godot -v -e --path demo-project --headless --quit-after 100
mkdir -p builds/Windows
godot --path demo-project --headless --export-release windows-desktop
See setup guide Compiling for Web with godot.
Requires a custom extension built Compiling for the Web: GDExtension
The default export templates do not include GDExtension support for performance and compatibility reasons. See the export page for more info.
You can build the export templates using the option
dlink_enabled=yes
to enable GDExtension support:
# Build libraries for openkcc
scons --directory godot-cpp platform=web -j4
scons platform=web target=template_release -j4
# Export debug web build
godot -v -e --path demo-project --headless --quit-after 100
mkdir -p builds/WebGL
godot --path demo-project --headless --export-release web
cp demo-project/coi-serviceworker.min.js builds/WebGL/coi-serviceworker.min.js
Host website for local testing via python -m http.server
python -m http.server --directory builds/WebGL
Documentation for the project is stored in the doc
directory
and built using DocFx.
Generate documentation using godot cli tool --doctool
and --gdscript-docs
.
Use gddoc2yml tool for
generating docfx docs.
# install gddoc2yml
python3 -m pip install gddoc2yml
# Install docfx if needed
dotnet tool restore
# Load project in editor at least once
godot -v -e --path demo-project --headless --quit-after 100
# Build xml based documentation
mkdir -p demo-project/doc/godot
godot --path demo-project --doctool doc/godot
godot --path demo-project --doctool doc/classes --gdscript-docs res://scripts
# Convert docs to yml
gdxml2yml --filter demo-project/doc/classes demo-project/doc/classes `
demo-project/doc/godot doc/api
# Create site with docfx
dotnet tool run docfx doc/docfx.json --serve
Style guides used for project by language:
Run tests for project with GUT
godot -d -s --path demo-project addons/gut/gut_cmdln.gd
C++ formatting via clang-format. Can be installed format via pip.
# Install
python -m pip install clang-format
# Find formatting via clang-format
clang-format src/*.cpp --dry-run
clang-format src/*.h --dry-run
# Fix formatting via clang-format
clang-format src/*.cpp -i
clang-format src/*.h -i
GDScript linting via godot-gdscript-toolkit
with the gdlint
command
# Install gdlint via pip
pip3 install gdtoolkit
# Run gdlint on openkcc files
gdlint openkcc demo-project/scripts demo-project/tests
Note: still in progress C# linting via dotnet format can be installed via dotnet in repo.
# Install via dotnet, uses .config/dotnet-tools.json
dotnet tool restore
# Run dotnet-format command via dotnet tool run
dotnet tool run dotnet-format .\demo-project\GodotOpenKCC.sln --check
Note: still in progress Markdown linting via markdownlint can be installed via npm.
# Install cli version via npm
npm install -g markdownlint-cli
# Run on local repo
markdownlint .