majikayogames / SimpleTerrain

A simple terrain system created for Godot 4.
Creative Commons Zero v1.0 Universal
23 stars 3 forks source link

Feature: Exposed vars for Layers/Masks for Collision? #2

Open luc0 opened 1 month ago

luc0 commented 1 month ago

Not and issue, but I was trying to change the layer/mask in code with no luck. I will keep trying, but It would be nice to have it exposed in a var!

thanks for the plugin!

majikayogames commented 1 month ago

Should be pretty simple, the 'chunks' variable holds the MeshInstance3D chunks. MeshInstance3D inherits property 'layers' from VisualInstance3D. If you added export var for 'layers' on SimpleTerrain, probably simplest way would be in update_lods, while iterating over chunks, just set chunks[x][z].layers = self.layers at the end of the current loop.

If i get a minute ill see if I can implement it. If you would like to, this method should work, I can accept a PR if you do this. Should only need a few lines or so. Just add the export var for layers. Also, there is some export variable hints: export(int, LAYERS_3D_RENDER) var layers_3d_render probably you want the render one to make a layer picker show in inspector.

if you are talking about the collision part, I would just create the collision object with the button in terrain settings, then set it once spawned. im not sure if i would accept a PR for collision since this solution already exists, may add unnecessary complication.

luc0 commented 1 month ago

Thanks, I wanted to add some layers and masks to the collision of the terrain. (I am experimenting with ragdoll) I resolve it manually adding some code. Now looking for a way to add to the editor. (I get some errors from Godot) so I will see if its godot's problem or something missing in the code. If I resolve that and you think it's useful I will send you a PR.

this is the updated docs for the editor: https://docs.godotengine.org/en/latest/classes/class_@gdscript.html#class-gdscript-annotation-export-flags-3d-physics