1
\$\begingroup\$

I am trying to use the superb GridMap in Godot 4 beta 5.

I have, so far, only 2 different types of meshes in my MeshLibrary.

  1. 1x1x1 cube
  2. 1x1 plane

My intention is to use the plane as a floor

All meshes were designed in blender, exported with GLTF 2.0, and their scales are all set to 1 and applied. They all seem to import perfectly.

This image illustrates my issue. On the left, you can see the cube and the plane as child nodes of the root node. The bottom of the cube and the plane are aligned with y = 0. On the right, the sames meshes, only in a GridMap. You can see that the cube is correctly positioned, but the plane is centered in it's cell in the x, y and z directions. Obviously, only the Y causes an issue.

If I untick "Center Y", the plane aligns properly but then the cube is 0.5m too low...

I'm not sure I'm phrasing the question correctly but:

How can I make sure the origins of all the meshes are aligned with the y=0 plane of the GridMap?

enter image description here

\$\endgroup\$
2
  • \$\begingroup\$ I haven't tried this in Godot 4, but giving how it was in Godot 3, I expect it to boil down to this: How were they aligned in Blender? \$\endgroup\$
    – Theraot
    Dec 16, 2022 at 11:50
  • \$\begingroup\$ @Theraot The bottom of each model is aligned with the origin. That is to say: The vertices of each mesh are all z >= 0. \$\endgroup\$ Dec 16, 2022 at 15:53

1 Answer 1

3
\$\begingroup\$

Select (or open) the MeshLibrary, and on the top bar you should see a "MeshLibrary" menu, there select "Update from scene" and select "Apply with Transforms", that should fix the issue.


Addendum:

I see the option, but it's greyed out. Any ideas?

The result of using "Apply with Transforms" should be equivalent to changing the origin of the Mesh Transform.

You can do that manually: Open the MeshLibrary in the inspector, go to the "Item" you want to displace (They are numbered in the same order they are displayed in the GridMap). Once you found the one you want (e.g. the "Rock"), go to the "Mesh Transform" property, there the last column is the origin (it is a 3x3 basis augmented with the origin vector). You can tweak the values to what you want (e.g. set the "yo" component to 1 or 0.5).

\$\endgroup\$
6
  • \$\begingroup\$ I see the option, but it's greyed out. Any ideas? \$\endgroup\$ Dec 16, 2022 at 16:50
  • \$\begingroup\$ Your edit is the correct answer, but I'd still like to know if it's possible to do it automatically. You can imagine that a large MeshLibrary could be very tedious to adjust every time there is a modification. \$\endgroup\$ Dec 16, 2022 at 18:29
  • \$\begingroup\$ @MatthewGoulart I really don't know why you had the option disabled. How did you create your MeshLibrary? \$\endgroup\$
    – Theraot
    Dec 16, 2022 at 18:30
  • \$\begingroup\$ @MatthewGoulart Did you create the resource and then added items and set their meshes? Don't do that. Create an scene with all the models, and then go to the "Scene" menu then "Export As…" and select "MeshLibrary…" then the option should be enabled, plus it is a much faster workflow to add the meshes. \$\endgroup\$
    – Theraot
    Dec 16, 2022 at 18:41
  • \$\begingroup\$ I did the Export as -> MeshLibrary Method... \$\endgroup\$ Dec 17, 2022 at 20:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .