Back to the reference
Hooks
Everything a scene or an object asks for while it is being built: loading, input, cameras, lights, sound, state and the frame loop.
71 symbols
Game
Scenes
Lifecycle
useSceneUnmountRuns your code once, the moment the scene disappears: when it is stopped, when it changes to another scene, or when the whole game is destroyed.useTimerRuns code later, in game time: once after a while, or again and again.useUpdateRuns your code once per frame, for as long as the scene is on screen.
Game objects
useSelfThe thing being built right now, so it can refer to itself later: almost always to end its own life once it has done its job.useSpawnPrepares a maker for component, so the scene can create as many of them as it likes, whenever it likes: while it is being built, from a frame, from a timer, from a click.useTransformGives this object a place of its own, and moves everything inside it.
Scripts
Input
useActionOne action, which is what most game code reads.useActionsThe game's named actions.useGamepadA gamepad, to ask in every frame what the player is holding, has just pressed, or how far a stick is pushed.useInputMapRemapping: what a game's controls screen is built on.useKeyboardThe keyboard, to ask in every frame what the player is holding or has just pressed.usePointerListens to the mouse and to touch: presses, releases, movement, and what is under the pointer.useVectorFour actions read as one direction: the way to move a character from the input map.
Store
State
Signals
Particles
Camera
useCamera2dGives the scene a camera, so its world can be bigger than the screen and scroll, turn and zoom.useCamera3dGives the scene a camera to look at its models through, and returns it.useFogPuts the scene in fog: its models fade into color between near and far from the camera.useScreenSpaceKeeps what is created here fixed on the screen, even while the scene's camera moves.
Lighting
useAmbientLightThe level everything is lit to before any lamp reaches it.useBlobShadowPuts a soft dark disc on the ground under something and keeps it there.useLightA light from far away, like the sun.usePointLightA lamp: it has a place, shines every way, and fades out with distance.useSpotLightA torch: a lamp that only shines inside a cone.
Geometry
useCircleGeometryA flat disc facing up.useConeGeometryA cone with a base.useCubeGeometryA cube, or any box shape: as wide, tall and deep as you ask.useCylinderGeometryA tube with a lid and a base.useIcoSphereGeometryA ball whose triangles are all about the same size.usePlaneGeometryA flat sheet lying like a floor, facing up.useTorusGeometryA ring, like a doughnut.useUvSphereGeometryA ball built as lines of latitude, the way a globe is drawn.
Animation
useSkeletalAnimationMakes a loaded model move: plays the movements it came with, and eases between them.useSpriteAnimationPlays a sprite's pictures in order, so it walks, attacks or spins.useTweenMoves a number from one value to another over time, so something can slide in, grow, fade or bounce without you writing the arithmetic for it every frame.
Post-processing
Color & palettes
Audio
useAudioThe game's volumes: the general one and one per channel, plus a way to silence everything.useAudioListenerPuts the game's ears on this object: every sound placed in the world is heard from where it is, and in a 3D scene, facing the way it faces.useMusicPlays a piece of music made of layers, and hands back the controls for it.useSoundPlays a sound, and hands back the controls for it.
Assets & loading
useLoadAtlasLoads a sheet written as a file: the image, how it is cut into frames, and the named runs of frames over it.useLoadAudioLoads a sound, and hands it back at once, still loading, for useSound to play.useLoaderKeeps count of what a scene is loading, for a loading bar or to wait before changing scene.useLoadFontLoads a bitmap font: an image with the characters drawn in it, and a file saying where each one is.useLoadGltfLoads a model made somewhere else: something sculpted in Blender, bought in a pack, exported from anywhere that writes glTF.useLoadLutLoads a colour grading table.useLoadPackLoads a pack: boxes and scenes somebody made in another project, with everything they need.useLoadPaletteLoads a set of colours for an effect to match a frame against.useLoadParticlesLoads an effect: what a puff of smoke or a shower of sparks is made of.useLoadShaderLoads a shader written in a file, so an effect can live beside the game instead of inside it.useLoadTextureLoads an image to draw with, and hands it back at once, still loading: a sprite made with it appears by itself when the file arrives, so nothing has to wait for it.
Physics
useCharacterBodynacatamalon/physics3dMakes this object a walking character: a capsule moved by asking the world what is in the way, and the thing that makes a room walkable.usePhysicsBody2dGives this object a flat shape to collide with.usePhysicsBody3dGives this object a shape in three dimensions to collide with.usePhysicsWorld2dOpens the flat simulation for this scene, and says how hard things fall.usePhysicsWorld3dOpens the simulation in three dimensions for this scene.
Math
Debug
useHelperAxisDraws the three axes as coloured lines from where it is placed: X red, Y green, Z blue, the colours every 3D tool uses.useHelperGridDraws a floor grid on the ground plane, the one every 3D editor shows, with its middle lines in the colours of the X and Z axes.useHelperLinesDraws any lines you like, and hands back the function that replaces them at any time.