wikis / Godot / wiki / concepts / scripting-and-lifecycle.md view as markdown report a mistake
Scripting & the Node Lifecycle
A script attached to a node gives it behavior by overriding engine callbacks. The script extends the node's type and becomes that node.
Core lifecycle callbacks
_ready()โ called once when the node and its children have entered the scene tree; do setup, cache node references here._process(delta)โ called every rendered frame;deltais seconds since last frame. Use for non-physics per-frame logic (UI, timers, input polling). Frame-rate dependent, so scale bydelta._physics_process(delta)โ called at a fixed rate (default 60 Hz) in sync with the physics engine; do movement and physics here for deterministic behavior._input(event)/_unhandled_input(event)โ receive input events._enter_tree()/_exit_tree()โ when the node is added/removed from the tree.
A first script
Attach a script to a node, then in _process/_physics_process read input and move it; in _ready grab references (@onready var sprite = $Sprite2D). Build behavior from these callbacks plus signals for events.
Pausing & process modes
Setting get_tree().paused = true pauses the game. Each node's process mode decides how it behaves while paused: INHERIT (default), PAUSABLE (stops when paused), ALWAYS (keeps running โ for pause menus), or DISABLED. This lets a pause menu stay interactive while gameplay freezes โ set the menu's process mode to ALWAYS.
Frame vs physics
Rule of thumb: movement/physics โ _physics_process (fixed timestep, deterministic); visuals/UI/other โ _process. Mixing them up causes jittery or frame-rate-dependent gameplay.
