Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SUGGESTION] Use GridMaps for Arena #11

Open
mechPenSketch opened this issue Nov 17, 2023 · 8 comments · May be fixed by #12
Open

[SUGGESTION] Use GridMaps for Arena #11

mechPenSketch opened this issue Nov 17, 2023 · 8 comments · May be fixed by #12
Labels
enhancement New feature or request

Comments

@mechPenSketch
Copy link

More info on GridMaps

Current system

To make the game map, Node3D Area have 2 nodes: MeshInstance3D Terrain which is the game map model and Node3D Tiles, which is a parent containing MeshInstance3Ds, each representing a tile on the game map.

Making a new map is tedious because you have to first mode the base map, then create tiles to cover all possible positions.

Using Gridmaps

While creating a MeshLibrary, another MeshInstance3D can be added (as a child?) for every mesh. This way, when a mesh is added into the GridMaps, this applies to both the mesh model and the tile.

@mechPenSketch
Copy link
Author

mechPenSketch commented Nov 24, 2023

Here is an example project:
grid_maps.zip

On the scene mesh_library.tscn, there are two kinds of terrains. Both are MeshInstance3D, and have their sizes adjusted to fit into the gridmap. They also each have a child node, Tile. The scene exported as a MeshLibrary, as mesh_library.tres.

On scene scene.tscn, there is a GridMap as a child node. In GridMap, Mesh Library is set to mesh_library.tres, and Size under Cell, Vector3(1, 0.5, 1). GridMap can be edited while selected in the scene tree.

Unfortunately, I don't have a way to prove that there is a Tile in each block of terrain, let alone access it. When it comes to access the blocks, the best I could do is to call get_cell_item(v3), which returns the MeshLibrary item index. Maybe adding a Tile as a child of a terrain block is the wrong approach.

BTW, how did you make a custom models with ArrayMesh when that's set for MeshInstance3D's Mesh? From looking at tutorials, scripting seems to be required, but your Arena's Terrain isn't attached to any script. Looking at your docs, its seems to be archieved by importing from Blender.

@mechPenSketch
Copy link
Author

An update to the example: grid_maps.zip

I have made one surface per item. However, this could be a problem if two items use the same grid. I cannot make a wall of the slope because of it.

Maybe instead, I should try to get a specific surface in a item?

@mechPenSketch
Copy link
Author

Another update: grid_maps.zip

This time, I used blender to customize my tiles. In Godot 4.0, you don't have to export your Blender files, instead you can use it directly in the editor.

Make sure Blender is enabled in Project > Project Settings...
godot_blender

And Blender 3 Path in Editor > Editor Settings... is set to the folder containing blender.exe:
godot_blender2

More information on using .blend in Godot can be found in Importing 3D scenes.

@ramaureirac
Copy link
Owner

Hi @mechPenSketch,

So the main idea in here is allow developers to "draw" an arena inside Godot editor using GridMaps. Something similar of what we can do on RPGMaker? (Please correct me if I'm mistaken).

If so, I still have some questions according to your PoC:

  1. This means every tile should be created separately and then used in Godot like "Kenney Assets" [1]? For instance taking as reference "Triangle Strategy" [2]: All blocks of the castle should be part of the GirdMesh and then the developer should put them together?

  2. How are we going to put a tile above the mesh using GridMaps? So far I'm not sure if is possible to attach a Mesh inside of a MeshGrid

[1] https://www.kenney.nl/assets/conveyor-kit
[2] https://cdn.mos.cms.futurecdn.net/dKBGAGnJXCoj7VeCg9QG5c.jpg

Thank you!
B.R.

@leonardoraele
Copy link

Having to manually position each individual tile in the right positions all over the arena is an uncacceptable workflow for a real project. I would love to see a better approach, since this is an example project.

I like the idea of using GridMaps because the tiles can be placed automatically by a script that reads the grid data. That is, assuming the Tile nodes are still needed at all—maybe, by reading the grid data, the arena.gd script might not even need the Tile nodes anymore.

Another idea is to write a @tool script that projects ray casts in a grid pattern covering the entire arena to figure out the positions and insert Tile nodes in the right places automatically.

@mechPenSketch It would be great if you could showcase your suggested changes in a fork to this repo. (github helps us by showing the diffs)

@mechPenSketch
Copy link
Author

@ramaureirac

  1. Yes, I think that's how it works.
  2. I initially thought I could access the children Tiles, but since GridMaps don't add cell items as its child node, I'm looking at other options.

@leonardoraele It'll be nice if I could access a specific face of a call item so I don't worry about tile nodes. Looks complex, but possible.

@ramaureirac
Copy link
Owner

ramaureirac commented Dec 22, 2023

@mechPenSketch IMO i don't think GrindMaps is necessarily a replacement for current Blender system, but a plus for giving more freedom in the way a user is creating a level.

I been playing with RayCasting and SurfaceTool for some months now in order to move Blender step into Godot vía @tool, something similar of what @leonardoraele mentioned. Maybe this feature can support both methods at same (One single mesh or GridMaps).

However my only issue is code base is ugly, and it got worse when moving to Godot 4, so probably I will have to clean and refactor some stuff before adding/accepting new scripts/features to this project.

@ramaureirac ramaureirac added the enhancement New feature or request label Dec 22, 2023
@mechPenSketch
Copy link
Author

^ It sounded good in my head, but yeah, the more I worked on it, the more I realized it's no less complecated.

@mechPenSketch mechPenSketch linked a pull request Feb 16, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants