# Functions
Most functions will only run if they are part of the scene tree. This seems to be the result of a recursive processing of the tree handled by Godot. So if something is not registered as part of the tree, Godot simply doesn't know to call it.
## \_init
Only called once after `new` (for `class_name` scripts) or `instantiate` (for loaded scripts). Runs before any potential `_enter_tree` or `_ready` callbacks.
Properties specified in the body of the script are set *before* `_init` is called. But `@export` properties are set *after* it, meaning that if you change those values in `_init` they will be overridden!
> If the script initializes its own node subtree, without a scene, that code should execute in `_init()`. Other property or SceneTree-independent initializations should also run here.
## \_notification
The `_notification` function is the default callback defined on `Object` and is the designated receiver of all internal notifications. This method is overridden by other objects, such as `Node`.
See [[Godot - Notifications]] for a listing of all notifications in one place.
It is important to note that the first notification arrives *after* initialization completes. `_init` is not invoked via `_notification` even though it might look like it.
# Notification Functions
These functions are called as part of Godot's notification system as defined on `Node`.
| Notification | Function | Situation |
| ------------------------------ | ------------------ | --------------------------------------------------- |
| `NOTIFICATION_ENTER_TREE` | `_enter_tree` | While tree is built, after node added, parent-first |
| `NOTIFICATION_EXIT_TREE` | `_exit_tree` | When removed from tree |
| `NOTIFICATION_READY` | `_ready` | After tree is built, child-first |
| `NOTIFICATION_PHYSICS_PROCESS` | `_physics_process` | Called regularly (60/sec-ish) |
| `NOTIFICATION_PROCESS` | `_process` | Called as often as possible |
| `NOTIFICATION_DRAW` | `_draw` | Called when drawing 2D |
### Process Mode
All processing can be halted on a node by setting `node.process_mode = Node.PROCESS_MODE_DISABLED`.
| Mode | | Effect |
| -------------------------- | --- | ------------------------------------------------------------------------------ |
| `PROCESS_MODE_DISABLED` | | No processing callbacks will be called for the Node |
| `PROCESS_MODE_PAUSABLE` | | Processing callbacks will cease when `SceneTree.paused` is `true` |
| `PROCESS_MODE_WHEN_PAUSED` | | Processing callbacks will be called *only* when `SceneTree.paused` is `true` |
| `PROCESS_MODE_ALWAYS` | | Processing callbacks will be called regardless of the `SceneTree.paused` state |
| `PROCESS_MODE_INHERIT` | | Use whatever mode its parent Node uses |
These modes are only used when the Node is actually in the `SceneTree`, if outside, there is nothing to call the functions in the first place.
The current processing state (based on the `process_mode`, pause state of `SceneTree`, and if the Node is in the `SceneTree`) can be checked with `node.can_process()`.[^1]
## \_enter_tree
When the node is added to the tree such as via `_add_child()`, this callback is run.
Useful if the node needs to do some setup before its children nodes are added.
Unlike `_ready`, `_enter_tree` will be called multiple times if the node enters the tree multiple times. Additionally parent nodes' `_enter_tree` is evaluated *before* their children.
> Child nodes are always added after their parent node, i.e. the `_enter_tree` callback of a parent node will be triggered before its child's.
## \_ready
Only called once after the node is added to the tree - such as with `add_child` or automatically if the entity is part of the node tree in the scene. If added to the tree again, it should not be called a second time.
Parent's `_ready` callback is evaluated *after* its children, so the children are always available to reference.
> For groups of nodes, the `_ready` callback is called in reverse order, starting with the children and moving up to the parent nodes.
> After removing a node from the scene tree and adding it again, `_ready` will not be called a second time. This can be bypassed by requesting another call with `request_ready`, which may be called anywhere before adding the node again.
\- official [docs](https://docs.godotengine.org/en/stable/classes/class_node.html)
## \_process
Called before every frame, the `delta` argument indicates the fraction of a second since the last time the `_process` function was called.
In single-threaded programs, `_process` is called *after* `_physics_process`. In a multi-threaded program their order is arbitrary. Either way, they are both called before the draw call.
Can be disabled with `self.set_process(false)`.
## \_physics_process
Only called if physics processing is enabled.
The `delta` argument should be the same between all calls. By default it targets running 60 times a second.
## \_draw
Something about overriding 2D drawing?
# Input Functions
## \_input
## \_shortcut_input
Runs after `_input` but before `_unhandled_input`. Can be toggled via `set_process_shortcut_input`.
- ? Not entirely sure what the purpose of this function is!
## \_unhandled_input
Only accepts input which has not been handled by some else (such as a menu/UI).
## \_exit_tree
Destructor.
## \_get_configuration_warnings
# Special Functions
## \_integrate_forces
# References
- [[Godot - Input Handling]]
## Official Documentation
- https://docs.godotengine.org/en/stable/classes/class_node.html
- https://docs.godotengine.org/en/stable/tutorials/best_practices/godot_notifications.html
- https://docs.godotengine.org/en/stable/tutorials/scripting/idle_and_physics_processing.html
## Opinions
- https://www.reddit.com/r/godot/comments/112w2zt/notes_on_event_execution_order_with_a_side_dose/
- https://www.reddit.com/r/godot/comments/1b2sa89/i_figured_out_the_enter_tree_vs_ready/
- https://www.reddit.com/r/godot/comments/17j32vs/when_using_the_navigation_system_why_are_process/
- https://www.reddit.com/r/godot/comments/14wr621/help_with_navigation_map/jrk5ae2/
## Articles
- https://geeksinsuits.com/index.php/2021/11/10/godot-node-execution-order-_enter_tree-_ready-_process-_physics_process-and-group-notes/
- https://kidscancode.org/godot_recipes/4.x/basics/tree_ready_order/index.html
- https://docs.godotengine.org/en/stable/tutorials/scripting/gdscript/gdscript_styleguide.html
## Q&A
- https://gamedev.stackexchange.com/questions/192180/difference-between-processdelta-and-physics-processdelta
- https://stackoverflow.com/questions/73098693/godot-process-vs-physics-process-i-need-a-valuable-example
- https://forum.godotengine.org/t/why-does-halting-the-physics-process-thread-also-halt-the-process-thread/4950
- https://github.com/godotengine/godot/issues/24699
## Godot 3.x
```cardlink
url: https://www.youtube.com/watch?v=imkBV_Mh4KY
title: "Godot Basics: Ready, Process, Physics Process!"
description: "We learn about the uses for _ready, _process, and _physics_process! Godot Basics is a series covering common Godot topics for newcomers to the engine.See my ..."
host: www.youtube.com
favicon: https://www.youtube.com/s/desktop/6561f2f9/img/favicon_32x32.png
image: https://i.ytimg.com/vi/imkBV_Mh4KY/maxresdefault.jpg
```
- http://kehomsforge.com/tutorials/single/process-physics-process-godot/
- https://www.reddit.com/r/godot/comments/oa5io6/when_should_i_use_process_or_physics_process_vs/
[^1]: https://docs.godotengine.org/en/stable/classes/class_scenetree.html#class-scenetree-property-paused