A Godot plugin for building 2D characters from separate body parts. Parts are placed through visual Marker2D sockets, equipped with data-driven weapons, and animated entirely in code, so a single rig can be reskinned and re-equipped at runtime without touching the scene.
- Part-based: Character assembled from body, head, mouth, legs, cape, shield and weapon
- Visual sockets: Placement driven by
Marker2Dnodes instead of hardcoded positions - Data-driven weapons:
ModularCharWeaponresource with per-type idle pose and attack curve - Code-driven animations: Blending, looping, queueing and a ready-made default set
- Built-in shadow: Adjustable visibility, opacity and distance
- Runtime swapping: Change skins, weapons, shield and cape on the fly
- Signals:
animation_started,animation_finished,animation_looped,attack_finished,facing_changed - 2D only: Production-grade, no deprecated APIs
- Copy the
addons/modular_charfolder into your Godot project. - Enable the plugin in Project → Project Settings → Plugins.
ModularCharis registered as a customNode2Dtype you can add from the scene dock.
# instance the character and register the default animation set
var character: ModularChar = preload("res://addons/modular_char/scenes/modular_char.tscn").instantiate()
add_child(character)
ModularCharDefaultAnimations.register_defaults(character)
character.play_animation("idle")
# assign a body part
var head: ModularCharBodyPart = ModularCharBodyPart.new()
head.scene = load("res://demo/assets/character_2/head.tscn")
head.scale = Vector2(0.48, 0.48)
character.set_head(head)
# equip a weapon
var weapon: ModularCharWeapon = ModularCharWeapon.new()
weapon.scene = load("res://demo/assets/weapons/sword.tscn")
weapon.animation_type = ModularCharWeapon.AnimationType.SWORD
character.set_weapon(weapon)
# act
character.set_facing(1.0)
character.attack()| Method | Description |
|---|---|
set_body(part: ModularCharBodyPart) |
Set the body part. |
set_head(part) / set_mouth(part) |
Set the head and mouth parts. |
set_leg_front(part) / set_leg_back(part) |
Set the front and back leg parts. |
set_cape(part) / clear_cape() |
Set or remove the cape. |
set_shield(part) / clear_shield() |
Set or remove the shield. |
set_shadow(part) |
Set the shadow part. |
| Method | Description |
|---|---|
set_weapon(weapon: ModularCharWeapon) / clear_weapon() |
Equip or remove the weapon. |
attack() -> void / is_attacking() -> bool |
Trigger and query the weapon attack. |
set_blocking(enabled: bool) / is_blocking() -> bool |
Enter or leave the block pose. |
set_weapon_aim_override(enabled: bool, angle_rad: float) |
Aim the weapon at a fixed angle. |
get_weapon_tip_position() -> Vector2 |
Global position of the weapon tip. |
| Method | Description |
|---|---|
register_animation(name, animation: ModularCharAnimation) |
Register an animation by name. |
play_animation(name, duration, transition_time) |
Play an animation with optional blend. |
queue_animation(name, duration, transition_time) |
Queue an animation after the current one. |
stop_animation() |
Stop the current animation. |
get_current_animation() -> String |
Name of the playing animation. |
get_animation_progress() -> float |
Normalized progress in [0, 1]. |
| Method | Description |
|---|---|
set_facing(sign_value: float) / get_facing() -> float |
Flip the rig left or right. |
set_shadow_visible(value: bool) |
Show or hide the shadow. |
set_shadow_opacity(opacity: float) |
Set the shadow opacity. |
set_shadow_distance(percent: float) |
Set the shadow size as a percent of its base. |
Weapons are ModularCharWeapon resources holding a scene, an offset and an animation_type. Each type drives its own idle pose and attack curve, so swapping a weapon swaps the whole motion.
| Type | Use |
|---|---|
SWORD |
Overhead melee slash |
SPEAR |
Forward thrust |
THROW |
Throwing motion |
CROSSBOW |
Crossbow shot |
GUN |
Quick recoil shot |
BOW |
Draw-and-release shot |
ModularCharDefaultAnimations.register_defaults(character) installs the built-in set: idle, walk, run, jump, hit, block and death.
Open res://addons/modular_char/scenes/modular_char.tscn and tune part placement visually through the markers:
Rig/BodyAnchor/HeadMarkerRig/BodyAnchor/MouthMarkerRig/BodyAnchor/CapeMarkerRig/BodyAnchor/ShieldMarkerRig/BodyAnchor/WeaponMarkerRig/LegFrontMarkerRig/LegBackMarkerRig/ShadowMarker
Open demo/scenes/test_world.tscn and run the project.
- Movement:
WASDmove,Shiftrun,Space/LMBattack,Jjump,Qblock - Panel: Switch skins, swap weapons, toggle shield and cape, toggle aim, fake hit, die, revive and scale the character
If this plugin helps you, consider supporting its development:
This project is licensed under the MIT License.
Made with ❤️ by Paulo Coutinho