The X and Y coords in behaviours are 0, 0

Hello All,
I’ve encountered a problem whilst using behaviors. When I try to access the X and Y coords of my object, they end up being 0, 0. This causes issues, as I can’t properly use it without it messing up the coords.

Am I missing something? Or is this a bug?

Hi, could you describe a little bit more what you mean by using behaviors? Which behavior do you use and when do you access the coordinates? Or do you mean you are making your own custom behaviors?

Can you provide a screen shot of your events that access the co-ordinates?

And as a starter, it should be ObjectName.X() & ObjectName.Y(). Note the X & Y are upper case (GDevelop is case sensitive), and require round brackets (it’s a function, not a property).

I am guessing you are talking about the onCreated lifetime function always saying that the position is 0. That is because this function is called before the object is fully initialized :skull:. I reported this issue on GitHub some time ago, but no fix was introduced yet. As a workaround, you can use an “initialized” boolean object variable in an “onScenePostEvents” to do something once after the object has been created and after it is fully initialized with its base position.