On Start
Type: Entry Point
Category: EVENT
Entry point that executes once when the Python component is created. Equivalent to the start() method of a KX_PythonComponent.
Properties
None.
Sockets
| Socket | Direction | Type |
|---|---|---|
| Exec | Output | Exec |
No input socket — this is the root of the tree.
When it executes
Once, on the first frame the component exists. If the object is destroyed and recreated (e.g., with addObject), the new object's On Start will execute again.
Typical usage
Variable initialization
[On Start] → [BT Set Blackboard: patrol_idx = 0]
→ [BT Set Blackboard: hp = 100]
→ [BT Set Blackboard: mode = 'idle']
Register initial state as BGE properties
[On Start] → [BTCustomTask]
self.own['ai_state'] = 'idle'
self.own['ai_hp'] = 100.0
Spawn sound
[On Start] → [BTCustomTask: play_sound('spawn')]
Initialization that must not repeat (vs On Update + Do Once)
On Start is preferable to [On Update] → [Do Once] when the initialization has no dependencies on other nodes that also use On Update, because:
- It's semantically clearer.
- It doesn't consume a Do Once tick every frame.
Difference from On Update
| On Start | On Update |
|---|---|
| Executes once | Executes every frame |
No useful deltaTime |
Can accumulate deltaTime |
| For initialization | For continuous logic |
Notes
- Code generated by On Start is placed in the
start(self)method of the component. - A tree can have multiple On Start nodes — each generates an independent code chain within the same
start()method. - If the tree has no On Start, the component's
start()method is empty.