DocsBehavior

Animation, transitions and overlays

The timeline

Open the timeline with Alt T, drag a box around keys to select them, drag one to move them all, press Play, then undo with Ctrl Z.

Open the timeline with Alt T. An animation belongs to a screen and has tracks of keyframes for a layer’s x, y, scale, rotation and opacity. Values add to the layout: x and y move the layer, scale and opacity multiply, rotation adds. Tracks can also drive a layer’s fill, corners, size and gradient.

Turn on Record, then move or rotate a layer on the canvas, with the arrow keys, or in the inspector’s X, Y and Rotation fields: the timeline writes the keyframe at the playhead. Size stays in the layout, so Record doesn’t key it; add a size track instead.

  • Autoplay plays it when the screen opens: the Intro of 01 Title and 02 Main menu in The Last Hunt · UI kit v2.
  • Loop repeats it: Breathe on 01 Title makes “Press any button” breathe.
  • Or start it from a button’s Play animation action, or from game code: ui.play("Hit") plays Hit on 09 HUD · Boss fight.

Len sets the animation’s length, and Space plays and pauses it with the pointer or focus in the timeline.

Keyframes

Click a key to select it and put the playhead on it. Shift or Ctrl click adds a key to the selection or takes it out. Drag from empty space in the lanes to draw a box: it selects every key it touches (hold Shift to add them), and a box over a layer’s top row takes the keys of all its properties. Ctrl A with focus in the timeline selects every key.

  • Drag any selected key and the others move with it, keeping their spacing. The key you hold snaps to frames, and no key goes before the start or past the end. Esc puts them back.
  • Left and Right move the selected keys a frame, 0.1 s with Shift.
  • With several keys selected, the Time field moves them so the earliest one is at that time, and Easing sets the easing of them all.
  • Delete removes them. A drag, a paste or a delete is one undo step.
  • Ctrl C copies keys, Ctrl X cuts them and Ctrl V pastes them at the playhead, in this animation or another one on the screen. They go back on the properties they came from, or onto the layer you select before pasting. Keys of one property can go on another of the same kind (Move X onto Move Y): select a key on that track first. When they run past the end, the animation grows to fit them.

From the keyboard, Tab moves through the keys, Enter puts the playhead on one, Shift Enter adds it to the selection or takes it out, Up and Down go to the nearest key on the track above or below, and Esc lets go of the selection. All timeline keys are in Keyboard shortcuts.

Fill, corners, size and gradients

Five properties add to the layout. Four more replace a value the layer already has: while the track runs, or holds after it finishes, it takes the place of the layer’s own value, and when the animation stops the layer’s value comes back. A track with no keys changes nothing.

To add one, press + (Add property track) on the layer’s row in the timeline and pick it. The list shows the properties the layer has no track for yet. Then set the key’s value in the key fields.

Timeline name Stored as Value What it drives
Fill colour fill A color The color of a text layer (styled runs keep their own colors), the bar of a progress layer, the fill of a shape, otherwise the layer’s fill
Corner radius radius Pixels All four corners. Below 0 counts as 0
Width, Height width, height Pixels The size of the layer’s box
Stop 1 colour … Stop 8 colour stop0 … stop7 A color The color of that stop in the layer’s gradient, counted in file order
Stop 1 position … Stop 8 position stopAt0 … stopAt7 0 to 1 Where that stop sits. Stops are drawn in position order, so two that cross swap

The gradient entries only list the stops the layer has. They change the layer’s main gradient, not extra fills. A color key is #rrggbb, #rrggbbaa or a $token. Colors blend in linear light, and an ease that overshoots, like Back or Elastic, stays inside the range of a color. A token is read when the animation starts.

{ "node": "<bar id>", "prop": "fill", "keys": [ { "t": 0, "v": "#3dcfc2", "ease": "inOut" }, { "t": 0.6, "v": "#f2c14e" } ] }

A Fill colour track on a frame that has a gradient is covered by the gradient, which paints over the fill. Animate the gradient stops instead. Document checks warn about it.

Size works the same in every runtime, and a size track never moves anything around the layer:

  • width and height replace the box. The top-left corner stays where layout put it, and rotation and scale turn around the center of the new size.
  • Layout still uses the stored size. The layer’s room in a row or column doesn’t change, so siblings stay put and a parent that hugs its children doesn’t grow. Only the layer is drawn larger or smaller.
  • The layer’s own children lay out in the new box. Content that no longer fits overflows, and Clip content decides whether it shows.
  • A side with no track keeps the size layout gave it. Text that wraps differently inside a width track doesn’t change the height.
  • A text set to shrink to fit keeps its size while a track runs, and fits once to the box it ends in.
  • A track on a screen’s root does nothing, since the root takes the host’s size.

Corners in Godot step in whole pixels. See known differences for that and the other small gaps.

When two animations hold the same property of one layer, the later one wins, and a finished entrance holds its last pose. A Fill colour track also wins over a hover or pressed look while it holds.

Easing

Each key’s ease shapes the segment after it. The Easing list names them Linear, Ease in, Ease out, Ease in-out, Back (overshoot), Elastic and Step (hold); the document stores linear, in, out, inOut, back, elastic and step. The curves are the same functions in TypeScript and GDScript, so motion matches on both sides.

Screen transitions

A screen can say how it appears when you go to it. Select the screen and set Transition in the inspector’s Screen section. Every screen of The Last Hunt · UI kit v2 fades in over 0.3 seconds:

"transition": { "type": "fade", "duration": 0.3 }
Type Effect
fade The old screen fades out while the new one fades in
slide Both move in a direction; the new screen enters from the opposite edge
scale The new screen grows from 92% to 100% while fading in

Time is the duration, from 0 to 5 seconds (0.25 by default). The speed curve is Ease out by default, or Ease in, Ease in and out or Linear. A slide Moves left by default, or right, up or down.

A Go to screen or Open screen over this one action can override the transition (or keep Screen default), and so can code:

ui.goto("12 Pause", { transition: { type: "none" } }); // web
ui.goto("12 Pause", {"type": "none"}) # Godot

The old screen stays mounted but takes no input until the new one has arrived. On the web, for people who ask their system for reduced motion, transitions are skipped, autoplay entrances show their end pose and autoplay loops don’t start.

Overlays

push opens a screen over the current one: a pause menu over the HUD. Screens below keep their state, follow data and keep animating, but take no input until they’re on top again. Focus moves into the overlay and comes back to the button that opened it. pop closes the top screen.

Under When opened over another screen in the inspector’s Screen section, each screen sets how it behaves as an overlay:

Option Default Effect
Screens below take no input On Off lets clicks reach the screens below, outside the overlay’s own layers
Closing returns focus to the opener On Focus goes back to the button that opened the overlay
Dim the screens below Off Draws a color over the screens below, black at 60% opacity unless you pick another
Keep inside the safe area Off Keeps the screen’s layers clear of notches and rounded corners

Without a dim, the overlay’s own background is what covers the screen below, so give it a semi-transparent fill.

ui.push("12 Pause")
ui.pop()
Updated View as Markdown