Guide for creating weapons with custom effects using the composition-based effect system.
Want to add a glass break sound to a weapon?
- Open your weapon scene (e.g.,
scenes/items/Brick.tscn) - Add a container: Right-click root → Add Child Node → Node → Name it "AudioEffects"
- In FileSystem, navigate to
scenes/effects/audio/ - Drag
PlaySoundOnDestroyEffect.tscninto the AudioEffects container - Select it → In Inspector → Drag your .wav file into the "Sound" property
- Save!
Your weapon now plays a sound when it breaks. No coding required!
Want an explosive sword?
- Open
scenes/items/Sword.tscn - Add a container: Right-click root → Add Child Node → Node → Name it "Effects"
- Drag
ExplosionEffect.tscninto the Effects container - Configure properties in Inspector
- Save!
Instead of creating custom scripts for each weapon type, you can attach effect components to any weapon to add special behaviors. Effects are modular and can be mixed and matched.
Every throwable weapon needs these core components:
- RigidBody3D (root) - the physical object
- PickupableBehaviour - makes it pickupable
- ThrowableBehaviour - makes it throwable
- SpawnableBehaviour - makes it spawn in rooms
- WeaponBehaviour - handles durability and destruction
Optional for melee attacks: 6. MeleeWeaponBehaviour - adds melee attack ability
Effects are separate nodes you attach as children of the weapon. They automatically trigger at specific events.
Recommended: Group effects in container nodes for clean scene organization:
Sword (RigidBody3D)
├── [Visuals]
├── [Behaviors]
├── AudioEffects (Node)
│ ├── PlaySoundOnAttackEffect
│ ├── PlaySoundOnEnemyHitEffect
│ └── PlaySoundOnDestroyEffect
└── VisualEffects (Node)
├── ExplosionEffect
└── TrailParticlesEffect
Benefits:
- Cleaner scene tree (collapsible containers)
- Easy to find and manage effects
- Group by type (audio, visual, gameplay)
- Scales well with many effects
Note: Effects work in containers OR as direct children - both work!
Triggers when the weapon breaks (durability reaches 0).
ExplosionEffect - Creates explosion on destruction
Properties:
- explosion_radius: float
- explosion_damage: float
- knockback_force: float
Triggers when the item is thrown.
Examples: trail particles, sound effects, temporary buffs
func execute(direction: Vector3, force: float, from_crowd: bool) -> voidTriggers when a thrown item lands (first collision only).
Examples: impact particles, ground effects, camera shake
func execute(collision_body: Node) -> voidTriggers when weapon performs an attack (melee or ranged).
Examples: attack particles, sound effects, screen shake
func execute() -> voidTriggers when weapon hits an enemy.
Examples: lifesteal, status effects (poison, burn), bonus damage
func execute(target: Node3D, damage_dealt: float) -> voidTriggers when weapon kills an enemy.
Examples: heal on kill, explosion on kill, spawn powerup
func execute(target: Node3D) -> voidTriggers when item is picked up by player.
Examples: sound effects, particles, UI notifications, player buffs
func execute(picker: Node3D) -> voidAdd sounds to weapons by dragging pre-built audio effect scenes from scenes/effects/audio/.
- Open your weapon scene (e.g.,
Sword.tscn) - Add "AudioEffects" container node (right-click root → Add Child Node → Node)
- Navigate to
scenes/effects/audio/in FileSystem - Drag the effect scene into AudioEffects container:
PlaySoundOnDestroyEffect.tscn- when weapon breaksPlaySoundOnAttackEffect.tscn- when player attacksPlaySoundOnEnemyHitEffect.tscn- when hit connects with enemyPlaySoundOnThrowLandedEffect.tscn- when thrown item lands
- Select the effect → Inspector → drag your sound file into "Sound" property
- Save!
Common setups:
- Metal sword: attack →
metal_impact_light.wav, destroy →metal_break.wav - Wood crate: throw landed →
wood_impact_heavy.wav, destroy →wood_break_splinter.wav - Brick: throw landed →
stone_impact.wav, destroy →stone_break_crumble.wav
Flask (RigidBody3D)
├── PickupableBehaviour
├── ThrowableBehaviour
├── SpawnableBehaviour
└── WeaponBehaviour (durability: 1)
ExplosiveSword (RigidBody3D)
├── PickupableBehaviour
├── ThrowableBehaviour
├── SpawnableBehaviour
├── MeleeWeaponBehaviour (durability: 10, damage: 25)
└── ExplosionEffect (radius: 3.0, damage: 30)
LifestealDagger (RigidBody3D)
├── PickupableBehaviour
├── ThrowableBehaviour
├── SpawnableBehaviour
├── MeleeWeaponBehaviour (durability: 15, damage: 20)
└── LifestealEffect (heal_percent: 0.25)
Heals player for 25% of damage dealt!
-
Create new scene (RigidBody3D)
-
Add mesh and collision shape for visuals
-
Add PickupableBehaviour (Area3D) with collision shape
-
Add ThrowableBehaviour (Node) - configure throw_force
-
Add SpawnableBehaviour (Node) - set categories
-
Add WeaponBehaviour (Node) - set max_durability, damage
-
Optional: Add MeleeWeaponBehaviour instead of WeaponBehaviour for melee
-
Drag and drop effects from
scenes/effects/folder:- Find effect in FileSystem panel (left side)
- Drag it onto your item in Scene tree
- Configure properties in Inspector
-
Configure RigidBody:
- collision_layer = 8 (item)
- collision_mask = 17 (environment + enemy)
- contact_monitor = true
- max_contacts_reported = 4
-
Save scene to
scenes/items/
Done! ItemRegistry will auto-discover your weapon.
All effects are available as pre-configured scenes in scenes/effects/:
Base Effect Templates (extend these to create custom effects):
OnDestroyEffect.tscnOnThrowEffect.tscnOnThrowLandedEffect.tscnOnAttackEffect.tscnOnEnemyHitEffect.tscnOnEnemyKilledEffect.tscnOnPickupEffect.tscn
Ready-to-Use Effects:
ExplosionEffect.tscn- Explodes on destruction
Just drag from FileSystem → drop onto your item → configure in Inspector!
To create a new effect type:
- Create a new script extending
OnDestroyEffect - Override the
execute()function - Add @export variables for configuration
- Attach it to any weapon!
Example:
extends OnDestroyEffect
class_name PoisonCloudEffect
@export var cloud_radius: float = 2.0
@export var damage_per_second: float = 5.0
@export var duration: float = 5.0
func execute() -> void:
print("Spawning poison cloud!")
# TODO: Implement poison cloud logicIdeas for more effects:
OnDestroyEffect:
- FireEffect - Sets area on fire
- IceEffect - Freezes ground/enemies
- ShardEffect - Spawns sharp fragments that damage enemies
OnThrowEffect:
- TrailEffect - Particle trail while flying
- WhirlwindEffect - Creates wind effect while airborne
OnAttackEffect:
- ScreenShakeEffect - Camera shake on attack
- SlowMotionEffect - Bullet time on attack
OnEnemyHitEffect:
- LifestealEffect - Heal player based on damage dealt
- PoisonEffect - Apply poison damage over time
- StunEffect - Temporarily disable enemy
OnEnemyKilledEffect:
- HealOnKillEffect - Restore player health
- PowerupSpawnEffect - Drop special items
- ChainExplosionEffect - Explode and damage nearby enemies
OnPickupEffect:
- SoundEffect - Play pickup sound
- BuffEffect - Grant temporary player buff
- UINotificationEffect - Show pickup message