Grid map at runtime?
Asked Answered
A

28

0

I wasn't sure where to go with this, so I guess I'll post here. Suppose I want a grid map at runtime to place things in game, how would I go about doing this? Do I have to code the sizes of blocks I want, and if the cursor or whatever is within range of the block, fix the object there? Or is there an easier way to do this? It's the only method I can think of at the moment.

Pardon me if this is easy, I've only used grid maps in Godot that already had things placed at runtime.

Asymptotic answered 3/7, 2022 at 1:12 Comment(0)
I
0

See the documentation, you can call functions such as set_cell_item(). But you have to code the interaction yourself.

https://docs.godotengine.org/en/stable/classes/class_gridmap.html

Imperforate answered 3/7, 2022 at 1:16 Comment(0)
A
0

That could work, but it's not exactly placing meshes all the time, per say? Other times it would be sort of like selecting two points and having something stretch or have several of one object spanned from point A to B. Mostly meshes, tho. This will give me a good head start.

Asymptotic answered 3/7, 2022 at 1:30 Comment(0)
I
0

Yes, that was way I meant by coding the interaction yourself. You can use ray casts to get the collision point (in world space) then use world_to_map() to get the cell of that click. From there you could set the cell to a particular asset using set_cell_item(), or track multiple clicks if you want to draw a line of assets, or a selection area, etc. but you have to code it.

Imperforate answered 3/7, 2022 at 3:0 Comment(0)
A
0

I'm sorry, the docs make no sense and rely on using a demo scene. Here, I found a video on grid maps that makes more sense. The grid map part starts almost halfway into the video, tho. I'll have to keep digging around for stuff on using the grid at runtime, however.

Asymptotic answered 4/7, 2022 at 23:24 Comment(0)
A
0

I crashed Godot with the large amount of models I need. (grumble, grumble...) Is there a limit to how many models a mesh library can have, or a limit on how big they are? There's a lot of them, but they are low poly.

Asymptotic answered 4/7, 2022 at 23:52 Comment(0)
C
0

In that video he uses "Create Trimesh Static Body" which makes no sense because those 3d shapes are just cubes. Godot should be able to run much faster if you just add the collision shape yourself then go to its shape property and generate a box shape. You can change the extents of that shape to match a cube or that elongated cube.

Calves answered 5/7, 2022 at 3:27 Comment(0)
A
0

I basically used the video to make my own mesh library. instead of using a pre-made library. I still don't know why Godot crashed, tho. I am also wondering if, despite its differences, I should be using Godot 4 as I want to keep this game constantly updated and have new content added over time.

However, I don't know if 4x will crash as well. That was weird.

I'm mainly looking into making my own mesh library that won't crash Godot ATM.

Asymptotic answered 5/7, 2022 at 9:31 Comment(0)
B
0

I remember a Voxel Game demo in official asset library. thogh it didn't used grid map... it do look like minecraft (using "chunk" to generate blocks)

Bancroft answered 5/7, 2022 at 13:16 Comment(0)
A
0

Maybe it would work? Do you have a link?

What I'm trying to accomplish here is a game sort of like Sims, or maybe The Infected? I want the player to be able to use the grid to make walls and such. It's not easy, and wanted to start with the very core mechanics. I also have to build the pre-made, basic world.

I use real models, though, not just blocks. Check out Synty Studios, it's where I get them.

Asymptotic answered 5/7, 2022 at 13:25 Comment(0)
A
0

Also... all my models are completely sideways when I import them? I switched to 4.x for this project only, but even with 3.x I get this:

How do I fix it so I can turn the meshes into a proper, not-so-sideways library? My floor comes on the grid standing up.

Asymptotic answered 5/7, 2022 at 16:32 Comment(0)
A
0

Update: I got my first grid map working. It was just a test, but I'm not complaining. I'll keep fiddling around with stuff, and see what happens.

Asymptotic answered 5/7, 2022 at 20:15 Comment(0)
E
0

blender is z-up godot is y-up. In your export settings there should be an option to export y-up.

Endamoeba answered 6/7, 2022 at 1:8 Comment(0)
A
0

Wait, you mean in Godot there are settings for this, or Blender? I haven't used Blender in ages, this is the source files directly from the Synty Studios store.

I can alternatively do this the very long way, and put each mesh in manually, and doing so makes them not sideways, which is useful but very strange. Additionally, it's time-consuming, but then I can set up a lib for each mesh type very easily, ie a lib for ground, one for buildings, interiors, exteriors, etc.

Asymptotic answered 6/7, 2022 at 1:27 Comment(0)
E
0

In blender, but if you are using bought assets from who knows what app, then YMMV. 🤷‍♂️

Endamoeba answered 6/7, 2022 at 4:49 Comment(0)
I
0

You can define the orientation for the gridmap itself, and also each asset in a grid cell.

Imperforate answered 6/7, 2022 at 6:21 Comment(0)
I
0

There are a bunch of hotkeys that control the gridmap. ASD rotate the item, ZXC set the axis of the grid, and QE moves the plane. I cannot find where these are documented anywhere, though. Also Gridmap extends Spatial, so you can move and rotate it just like any other 3D object, for example rotating the x by 90 degrees for the whole thing.

Imperforate answered 6/7, 2022 at 6:28 Comment(0)
A
0

In case anyone is curious...

https://www.syntystudios.com/

When I used Unity, I swore by these assets for the most part. 😉

Asymptotic answered 6/7, 2022 at 12:46 Comment(0)
A
0

It seems like I will have to do this the hard way, Godot doesn't like the demo scene.

Oh well, at least now I can be picky about everything.

Asymptotic answered 6/7, 2022 at 13:37 Comment(0)
A
0

I have my first real mesh lib done, but only four of its items are visible. Plz help?


Asymptotic answered 6/7, 2022 at 14:26 Comment(0)
B
0

Asymptotic here it is:
voxel demo

Bancroft answered 7/7, 2022 at 23:2 Comment(0)
B
0

Asymptotic about "not visible" thing, I also experienced once.
What I did was try to delete the MeshLibrary and re-export one. Though what really worked is re-export and replace the old file (not deleted manually) with an option on (My godot is languaged Chinese, I think it might be "replace" or "keep" or "adding" thing?... in the exporing(?to MeshLibrary) window)

Bancroft answered 7/7, 2022 at 23:17 Comment(0)
A
0

Sorry, can someone please break that down for me?

Asymptotic answered 8/7, 2022 at 13:40 Comment(0)
A
0

Bump? And what do you mean by re-export? And I noticed the meshes look massive on the grid. I thought I resized these... Not sure why they got huge again.

Asymptotic answered 13/7, 2022 at 22:48 Comment(0)
B
0

Asymptotic actually it's "convert to mesh library " again
XD I use Chinese interface so didn't get the exact English name

Bancroft answered 21/7, 2022 at 9:57 Comment(0)
A
0

Ik. I have used that button so many times, it is not funny. Thanks for clarification, tho. 😃

Asymptotic answered 21/7, 2022 at 10:18 Comment(0)
B
0

Asymptotic
sorry for didn't watched the video you shared (I need VPNs to watch youtube)

Is that problem solved? if not maybe you can show how your origin tscn's Node tree is arranged, or how does the MeshLibrary look like in the inspector? (you may see the items of the Library in Inspector)

or even share part of your files if you could(?)

Bancroft answered 22/7, 2022 at 23:32 Comment(0)
A
0

Bancroft I didn't fix it "yet", but I think I know what I did. I just haven't gotten around to trying it yet as it's going to take a while. If it doesn't work, I will show you what I have.

Asymptotic answered 22/7, 2022 at 23:35 Comment(0)
M
0

Asymptotic Hi! I hope you have solved this issue by now, but I just wanted to reopen this thread to share what worked for me in case any other person is having the same issue.

Apparently, as of now Godot has a limitation regarding the exported mesh node structure:

Through a quick analysis, I found out that the actual issue is that the MeshInstance node in the exported .glf files are too deep in the hierarchy for the Godot exporter to find when it's generating the mesh library. What I am doing to work around this issue is simplifying the hierarchy the most I can in Blender before exporting the model, making sure that the actual mesh is as close to the root as it can. This trick has consistently worked for me so far.

Mcclurg answered 5/3 at 20:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.