All Questions


Thomas Sorger

Change of Grid_Size

sorry if this is a Beginner-Question but it really drives me nuts.

So  i changed my Game to a Grid-Size with 16 px, made my own field and altered the "Grid.tres"-Cell Size to 16 x 16.

What I got, was a nice 16x16 white quare that was sadly off to the mouse by 40 Pixel. 
Somehow it changed every Coordinate to plus 40.
For example (0,0) to (40 px,40 px) no matter what I did.

Only after I change this line in the to (16, 16) it worked:

export var cell_size := Vector2(80, 80)

Now I'm somewhat confused - shouldn't the Grid.tres override the export var?

Actually for some cases it does - for example the 16x16 Cursor and movement look fine too.
I even tried your final version. Just changed to 16x16 same result.

Hope there is an explanation, or else I'm not using export vars anymore :)

  • Nathan Lovato replied

    That's definitely a weird bug. I just tested it and could reproduce. Normally, using an exported variable should just work. It's especially weird the issue happens only with the offset with the mouse position.

    It seems to be an engine-side bug that's specific to resources, with the value not properly updating on exported variables. Some kind of edge case.

    When changing the cell's size in the inspector, and printing the cursor's position in _ready, I still get a start position of (40, 40). In my case, it should be (15, 15). After changing the line of code in the script, though, it does update as expected.

    I'll have to check Godot's bug tracker and get back to you.

    In any case, this seems only to happen with resources. So you can keep using exported variables on nodes.

  • S
    Thomas Sorger replied

    Thanks for checking and the Info.
    I really thought I lost it :)