Allow Expressions in Object Instance Properties

At my job, I usually have to interact with a few different “no code” UI solutions, such as Microsoft PowerApps/PowerAutomate.

One thing I’ve seen in those solutions, that is missing in GDevelop’s IDE, is the ability to set an object properties to an expression without an event.

As an example, if I have an object I want to center in the scene, within PowerApps I can just set the x/y coordinates of an instance to ScreenWidth() / 2 and ScreenHeight() / 2. This way it is reflected immediately in the preview.

In GD5, I can do this through events, but then my objects in the editor are no where near reflective of preview.

I think it would be beneficial if I could just go to the object instance in the IDE and just put the expression into the X/Y boxes and have the editor reflect those changes. I’m sure there are other properties for instances that would benefit from allowing expressions directly as well.


Text objects :slight_smile:
But imagine you have GDevelop in window mode on the right half of your monitor, and you set the X position of an object to ScreenWidth() / 3 in the IDE, the object would be hidden (and move around if you move the GDevelop window)? :thinking: (screen width, not scene window width)

1 Like

It a bit same in Blender , you can write in the properties, for example you can use math and the result is automatically compute.

It would be nice to have a similar feature.
Maybe with a special expression for allow to write and keep the text visible in properties.

expression (myobject.X()-ScreenWidth()/2)

And for the current object.

expression (this.X()-ScreenWidth()/2)

1 Like

I suppose it depends, but it could always just be a documented thing to use SceneWindowWidth instead.

The main problem would be that expressions doesn’t really exist in the ide. To know what expressions exist and to what function call it should be generated it uses a sort of description of it, but the actual code of the expression is either in GDJS or in an extension include, and both are not even loaded in the IDE, only at execution time. And most of them are made for working only on the running game and would crash on the IDE. It would be very tricky to implement.

hmm… I wonder if we can’t do full expressions, maybe some helper buttons could be useful?

Like, underneath the box for X coordinates, 1/4, 1/3, and 1/2 buttons that place the object at the respective X coords for the screen (assuming the camera is at 0,0), same for Y.

I would also piggyback on Gruk’s suggestion, and objects should expose all of their properties. You should be able to update a text object (Both text and font/font size) from the properties panel without having to double click into it, same with BBtext, etc).

1 Like

Maybe adding a checkbox for X and Y like
:ballot_box_with_check: Center X to screen

:ballot_box_with_check: Center Y to screen

1 Like