com um clique
stemstudio-behaviors
// Behavior discovery, creation, update, attach/detach, and configuration in Studio 3D. Use for built-in behavior reuse first, then custom behavior authoring only when needed.
// Behavior discovery, creation, update, attach/detach, and configuration in Studio 3D. Use for built-in behavior reuse first, then custom behavior authoring only when needed.
| name | stemstudio-behaviors |
| description | Behavior discovery, creation, update, attach/detach, and configuration in Studio 3D. Use for built-in behavior reuse first, then custom behavior authoring only when needed. |
Primary skill for behavior reuse and custom behavior workflows.
Use this skill when the task involves:
Behavior work is always pack-first:
Start with:
python scripts/list_behaviors.py
python scripts/list_behaviors.py --filter "movement"
If a candidate exists, inspect it before attaching:
python scripts/get_behavior.py --behaviorId "BEHAVIOR_ID"
python scripts/attach_behavior.py --target "Player" --behaviorId "BEHAVIOR_ID" --config '{"speed":5}'
Update config later with:
python scripts/set_behavior_config.py --target "Player" --behaviorId "BEHAVIOR_ID" --attributesData '{"speed":8}'
Detach when needed:
python scripts/detach_behavior.py --target "Player" --behaviorId "BEHAVIOR_ID"
Write the code file and metadata file, then create the behavior:
python scripts/add_behavior.py --name "Rotate" --code /tmp/rotate.js --metadata /tmp/rotate.behavior.json
Important:
add_behavior.py returns the real behaviorIdbehaviorId for attach, config, and updatesGlobalBehaviorsHost; attach to the actual owning object or a dedicated host objectTypical flow:
/tmp/behavior.js/tmp/behavior.jsonadd_behavior.pycodeValidationcodeValidation contains errors, fix and retry before attachingbehaviorIdattach_behavior.pyget_behavior.py or scene inspectionpython scripts/update_behavior.py --behaviorId "BEHAVIOR_ID" --code /tmp/rotate.js --metadata /tmp/rotate.behavior.json
Treat codeValidation exactly the same as on create:
Always use batch scripts for 2+ objects:
python scripts/batch_attach_behaviors.py --targets Enemy1 Enemy2 --behaviorId "BEHAVIOR_ID" --config '{"aggressive":true}'
python scripts/batch_detach_behaviors.py --targets Enemy1 Enemy2 --behaviorId "BEHAVIOR_ID"
Use these built-in navigation helpers for AI patrols, pathing, and off-mesh links:
python scripts/add_navmesh.py --target "Default Scene" --autoGenerate true --agentHeight 1.8 --agentRadius 0.45
python scripts/rebuild_navmesh.py --target "Default Scene"
python scripts/add_navmesh_connection.py "RooftopStart" "RooftopEnd" --bidirectional false --radius 0.75
python scripts/add_waypoint_path.py --name "MarketLoop" --position 0 0 0 --loop true
python scripts/add_waypoint.py --path "MarketLoop" --position 12 0 8 --order 0 --waitTime 1.5
For navmesh baking, configure static level geometry with physics first when using --onlyPhysicsMeshes true.
Before writing custom code:
stemstudio-game-engine for engine API detailsstemstudio-eventbus for event names and messaging patternsstemstudio-lambdas when the behavior reads or writes ECS-style datastemstudio-scripts when the behavior should pull shared helpers via @import (or when extracting helpers a behavior duplicates)stemstudio-game-design when the mechanic is part of a bigger gameplay loopstemstudio-input-manager before writing any custom movement / vehicle / flight / character controller — it documents keyboard/gamepad/touch parity, the -Z forward convention, physics tradeoffs, and why you must NOT copy BipedalControl's internal axis math. Skipping this is the source of "W moves backward", "model is inverted", "works on keyboard but not phone", and "plane flies but cannot land" bugs.1. No class, no export, no import.
Behavior files are executed as plain scripts in a shared context. ES module syntax is not supported and will cause a parse error.
// ❌ WRONG — never do this
import EventBus from "/EventBus";
export default class PlayerJump { ... }
// ✅ CORRECT — plain this.method = function(){} assignments at the top level
this.init = function(game) { ... };
this.update = function(deltaTime) { ... };
2. No class bodies — lifecycle methods are top-level this.x = function(){} assignments.
There is no class, no constructor, no prototype. Every lifecycle method is assigned directly on this.
3. EventBus is a global — never import it.
EventBus is injected by the script factory and available as a global. Do not import it.
// ❌ WRONG
import EventBus from "/EventBus";
// ✅ CORRECT — EventBus is already available as a global
this.update = function(deltaTime) {
EventBus.instance.send("player:jumped", { source: this.target.name });
};
Behavior code must:
this.method = function(){} syntax for all lifecycle methodsinit(_game) -> onStart() -> update(deltaTime) / fixedUpdate(fixedDeltaTime) -> onStop() -> dispose()this.game = gamethis.target only after onStart()this.erth for assets, cross-behavior lookups, lambdas, camera helpers, scene helpers, and poolingdispose()let game;
let erth;
let target;
this.init = function(_game) {
game = _game;
erth = this.erth;
};
this.onStart = function() {
target = this.target;
};
this.update = function(deltaTime) {
if (!target) return;
};
this.dispose = function() {
target = null;
};
this.erth.behaviors.find(target, id) and this.erth.behaviors.findAll(id)game.inputManager members such as getAction(), getMotion(), and getMouseTouchPosition()touchControls unless the user explicitly chooses desktop-only.await erth.scene.addObject(gameObject, parent)await erth.asset.image.createTexture(...), await erth.asset.model.createInstance(...), and related findByName() helpersgame.behaviorManager.sendEventToObjectBehaviors(target, msg, data) and receive them in this.onEvent = function(msg, data) {}motion("forward", ...) reading must move the controlled object in -Z (or (0, 0, -1) rotated by its quaternion, for object-local forward). See stemstudio-input-manager for the canonical motion-axis rule and ~/.claude/stemstudio-docs/architecture.md "Coordinate Convention".this.game = gamethis.THREE or this.game.THREEEventBus.send(...)this.config.attributesthis.findBehavior(...) or this.findBehaviors(...)init(game) with shadowing assignment or init() with no _game parameterthis.erth, or attribute JSON shape: ~/.claude/stemstudio-docs/behavior-system.md~/.claude/stemstudio-docs/behavior-catalog.md~/.claude/stemstudio-docs/game-design-patterns.md~/.claude/stemstudio-docs/asset-loading-patterns.md~/.claude/stemstudio-docs/editor-preview-callbacks.md~/.claude/stemstudio-docs/performance-patterns.md~/.claude/stemstudio-types/stem-types.d.ts~/.claude/stemstudio-types/stem-events-registry.jsonIf you open an example from examples/, normalize it to the closure pattern and current validator rules before reusing it.
Verify behavior work by checking:
codeValidation is clean enough for the change you are shippingTypical verification commands:
python scripts/get_behavior.py --behaviorId "BEHAVIOR_ID"
python scripts/list_behaviors.py --filter "Rotate"
InstancedMesh for many identical objects (trees, bullets, coins). One draw call instead of hundreds.Vector3, Quaternion, Matrix4, Raycaster etc. once (e.g. in onStart), reuse in update(). Never new inside the frame loop.matrixAutoUpdate = false on static objects, then call updateMatrix() once.this.method = function(){} assignmentsGlobalBehaviorsHost instead of the owning objectbehaviorIdcodeValidation feedback from create or updatedispose() cleanupstemstudio-game-engine for engine and runtime APIsstemstudio-eventbus for inter-behavior communicationstemstudio-lambdas for structured gameplay datastemstudio-scripts for shared @import helper modules consumed from behavior codestemstudio-game-design for mechanic and loop designAsset search (local and external), asset metadata lookup, model import, and 3D model generation for Studio 3D. Use for finding, inspecting, downloading, and placing 3D models in the scene.
Scene lighting, light object properties, fog, background, tone mapping, and post-processing for Studio 3D. Use for mood, atmosphere, shadows, and visual environment setup.
Add sound effects and audio to 3D scenes in Studio 3D game engine. Use when the user asks to add sounds, music, audio feedback, or sound effects to objects or events. Covers the genericSound behavior for event-triggered audio, audio resource management, and common patterns like ambient sound, collision SFX, UI click sounds, and background music. Examples include "add a sound when the coin is collected", "play background music", "add footstep sounds to the character", or "make the button click sound".
Camera type, perspective, and configuration for Studio 3D. Use for camera type selection, FOV, clipping planes, and genre-appropriate camera setup.
Master routing skill for StemStudio ACP work. Use for broad or ambiguous requests such as "make a game", "build a scene", "improve this", or any task that needs skill selection, scene inspection, staged execution, and clean scene hierarchy.
EventBus guidance for behavior-to-behavior messaging in Studio 3D. Use when behaviors need decoupled communication, topic design, or event lifecycle cleanup.