Custom behaviour: onCreated object position is always 0,0

Hello all!

As stated in the topic title, I’m having an issue with custom behaviours: when the onCreated function is fired, the object position is always 0,0. Object only goes to propper world position afterwards. I’d need to access the final position upon creation to set some variables instead of using the general event sheet to set them…

Is there a way to do this? Am I missing something?

Can you put here events Screenshot please?

When the game starts and the instance is created (running onCreated), that log shows 0,0.

If I log the position in doStepPreEvents it logs the correct object position.

This is the scene, object is the fly, which is not at 0,0
image

I tried using “at the beginning of scene” as a condition, but it still shows 0,0

That has been a known issue for a while: Behavior lifecycle function onCreated called early · Issue #3663 · 4ian/GDevelop · GitHub

That’s the solution I went with (using a run once event in onprestepevents), but it didn’t feel right considering the structure of functions.

Good to know it wasn’t a case of my lack of understanding, anyway. Looking forward to the resolution.

Hello,
I wanted to use OnCreated in a personal behavior and found the same inconvenience to retrieve the object’s X,Y coordinates.
To get around this, I set the coordinates manually in the behavior properties. This works unless the object is created randomly.
It’s true that if this could be corrected, it would be a plus.
Alexandre

Another workaround is using an event with a trigger once in the postsceneevents >:P

Hi, this bug is causing issues with a behavior I’m trying to implement today. Also, it’s pretty interesting that this bug has been around for so long. I guess it carries quite a bit of technical debt.

I’m writing this comment just to bring it back to everyone’s attention. Thank you :waving_hand: