How to get custom data from a surface?

Godot Version

4.2.2 stable

Question

Hey all, quick question. I have a player character that kicks up dust/debris when traveling. I was wondering, what is the best way to find out what kind of debris should be kicked up? For example, on sand, puffs of sand dust; on grass, little bits of grass leaves.

My initial thought was to have a bunch of Area3D’s scattered around, each with variables such as “terrain type” and “debris type” and “sound effect”, etc, and use the “body_entered()” and “body_exited()” signals. But, that seems like a clumsy solution. Is there a simpler/more elegant way to store/retrieve custom surface data?

Just to be clear, I’ve got a “world” mesh that has several terrain types on this single mesh. Thank you!

You might be able to get the physics material of the mesh your standing on. Have different physics materials for different dust materials.

I believe the Area3D route is the way to go.

An alternative is to render an appropriately lower res image of the map replacing the rgb channels with data that represents the terrain data. Query the data with Image.get_pixel(). An advantage is you can “paint” the terrain data.

  • You could also use this in a shader