|
|
|
 |
Reply From: |
johnygames |
Take a look here: GridMap — Godot Engine (stable) documentation in English
You should use Gridmap’s methods instead of its properties. More specifically, you need the get_cell_item ( int x, int y, int z )
method, which finds what item is on a specific location, and the get_meshes ( )
method, which outputs all the meshes that you have placed. If you want to change the item of a cell, you might want to use the set_cell_item ( int x, int y, int z, int item, int orientation=0 )
method, which changes or erases a cell item at the specified xyz coordinates. Check the other methods as well, you might find something that suits your needs.
You use the Gridmap methods simply by making a script and calling the methods. For example, you can do this:
extends GridMap
func _ready():
var meshL = get_meshes().size() # gets how many meshes you have placed
var meshC = get_cell_item(10,10,10) # finds item at xyz coordinates
print(meshL, meshC)
Finally, you could use the Gridmap as is and only place MeshInstances where they are absolutely necessary. For example, if you know a box will have to be moved, make this box a separate MeshInstance.
In any case, I think that Gridmap is way faster because it makes a single draw call to the GPU, but I am not sure.
Does this answer your question? If it does, please mark this answer as best.
Thank you for your kind reply :). I checked the documents, and I tried get_cell_item and other methods, but it was Vector3, not Node. But to do what I want to do, I think we can use the separate MesshInstance as you say. Thank you!