#3663·GDevelop

Behavior lifecycle function onCreated called early

Author: BouhCreated Feb 17, 2022Updated Aug 20, 2026
Labels✨ enhancement⚙️ Addition required in GDevelop.js/GD Core (C++)

Discussed in https://github.com/4ian/GDevelop/discussions/3634

Originally posted by arthuro555 September 11, 2021

Description

Not sure if this should be considered a bug, but the behavior lifecycle onCreated function is called before the object is completely initialized. For example, it does not yet contain its creation position. A workaround for this is to put an event with a trigger once in the pre-/postevents lifecycle functions but this is not viable since if an object is created in events, the behavior will be in an invalid state until the end of the events is reached (for the lifecycle functions to be called).

To Reproduce

  1. Open this game: game.zip
  2. See that the event is in onCreated and how the default position is not set on a preview
  3. Enable the event in onPreEvents and see how it now works