Guides
Follow practical examples for common game tasks, from moving a character to loading a scene and saving progress.
Scenes and assets
- Load a modelA .glb or .gltf file loads as a ModelAsset, and a Model component instantiates it under an entity.
- Spawn a prefabA prefab is a scene file (ADR-0005): the same ignifx.scene format, loaded as a SceneAsset and stamped out with world.instantiate.
- Spawn a prefab on clickA click is a ray.
Rendering and motion
- Tween a transformapp.tweens is core: it interpolates any number, Vec2, Vec3 or Quat property of any object, on the game clock, in PostUpdate — so a tween honours time.timeScale and stops with app.pause() unless it asks for updateWhenPaused.
- Instance many meshesOne mesh, one material, thousands of copies, one draw call.
Shaders
- Write a custom shaderA .wgsl file whose // @ignifx pragma comments **are** its declaration is a material family of your own: the pragmas say which attributes the vertex stage reads, which engine uniforms it wants, and which uniforms, textures and defines a material may set.
- Add a surface shaderA surface shader is a small piece of WGSL layered onto a **PBR** material, so the engine keeps doing the lighting: shadows, image-based lighting, fog and tone mapping all still apply, and your code only says what the surface is made of.
- Add a custom post processA // @ignifx post file is one full-screen fragment function.
Particles
- Play a particle effectAn effect is a document — a .particles.json, or the same object built in code by particleDefinition(preset, overrides) — and a ParticleSystem component plays it.
- Burst particles on a hitemit(count) spawns particles at the system's current clock whether or not it is playing, which is what a one-off impact wants.
- Draw particles in 2DParticleSystem2D plays the same .particles.json a 3D ParticleSystem plays, but draws it as sprites in a @ignifx/2d sorting layer, so torch fire sorts, blends and pans with the rest of the scene.
Terrain
- Load a heightmap terrainA .terrain.json says how big the ground is, where its heights come from, how it is chunked, and which texture layers blend across it.
- Walk on terrain@ignifx/terrain does not depend on @ignifx/physics: a terrain without physics costs no physics code.
- Scatter foliage on terrainTerrainScatter places instances on the terrain it shares an entity with — or on any ancestor's — by seeded rules: a density in instances per square metre, the splat layers a candidate may stand on, and the slope and height bands it must fall in.
Input
- Bind an action and read itGame code asks for "move" and "jump", never for a key code.
- Rebind a key at run timeperformInteractiveRebind listens for the next control the player touches and writes it onto one binding as an override.
3D
- Move a 3D character controllerA CharacterController is a kinematic capsule that collides and slides.
- Follow a character with a third-person cameraThirdPersonCamera is an orbit rig: it puts the entity carrying the Camera behind target, at distance, offset by shoulderOffset, and damps toward that pose.
- Raycast and catch a trigger in 3DTwo ways to ask the physics world a question.
2D
- Animate a sprite from an atlasTwo documents and two components.
- Load a tilemap and give it collisionThree components share the work.
- Move a 2D platformer characterCharacterController2D is a kinematic capsule or box that collides and slides through Rapier.
Audio
- Play a positional one-shot and a music loopThe mixer is a tree of named buses declared in a .audio.json: every sound plays on one, and a bus's volume multiplies through its children.
UI
- Build a pause menuGame UI in ignifx is HTML, and @ignifx/ui's Menu is the list widget a front end is made of: a title, rows that declare what they edit, and one selection model that keyboard, gamepad and pointer all drive.
Saving
- Save and load game stateapp.storage is the asynchronous key–value store behind save games, settings and input rebindings.
Tools
- Show a gameplay counter in devtools@ignifx/devtools draws the overlay; every number on its Stats panel comes from app.diagnostics, which is core.