Repository navigation
How to expose a script to the scene tree that is attached to an instanced foliage model. #959
Terrain3D versionv1.0.1 System informationGodot 4.5 Windows Ten, AMD 500Mb GPU, 8Gb ram. Is the issue reproducable in the demo?No response Issue descriptionThis is a background question on where I can dig into the codebase to expose a script that has been attached to a foliage model that terrain3d instances in. The attached script gets added to an area3d which is child of the meshinstance of a foliage model. `@tool enum Type { GRASS, BUSH, FLOWERS, TALL_GRASS } func _ready(): func _on_body_entered(body): func _on_body_exited(body): func get_foliage_type() -> int: To test this a manual instance was added to the scene and its plays perfectly, but whenever the player walks though an instanced foliage with terrain3d's foliage tool, the script never runs. Any pointers on getting this script exposed to the scene tree would be welcome. The objective of this script is to allow foliage sounds to be added to any foliage instance from terrain3d. LogsNo response |
Replies: 1 comment
|
This isn't an issue. Questions go here, or on discord.
Instances are part of a MultiMeshInstane3D within the rendering server. They're visual only. No physics. No scripts. That's how instancers work across all engines. Some systems instantiate copies of your scene objects with physics, scripts, and gpu particles, linked to the scenetree, but those aren't instancers. We have a pending physics generator.
You attached a script to a scene. When you applied that scene to the instancer it copied only the mesh resource and gave it to the rendering server for the MMIs. That scene with the script in it was never instantiated nor placed in the scene by us.
None of this happens because it's only a rendered mesh, not an instantiated scene.
Don't use an instancer. Place your full instantiated scene objects with a tool like assetplacer or scatter.
Or have your sounds done by footsteps based on texture using get_texture_id(). Or you could use a variation of code like our get_intersection() in gpu mode, combined with a foliage interaction shader to get feedback from the GPU when the interaction sphere is "colliding" with foliage. That should work, but only if you are good with shaders and understood exactly what I wrote. If not, do one of the two above. |
This isn't an issue. Questions go here, or on discord.
Instances are part of a MultiMeshInstane3D within the rendering server. They're visual only. No physics. No scripts. That's how instancers work across all engines.
Some systems instantiate copies of your scene objects with physics, scripts, and gpu particles, linked to the scenetree, but those aren't instancers. We have a pending physics generator.
You attached a script to a scene. When you applied that scene to the instancer it copied only the mesh resource and ga…