Detect physical material, however way possible?

Godot Version

4.3 stable

Question

I’ve searched the web for a while now and seems this is not well known, nor taught.

Normally I would have an easy time getting the physical material from either raycasts or collision data, but this seems to be well hidden within godot - forcing me to shout into the townsquare! :smiling_face:

This is normal for all games. Distinguish between things by setting up and later looking at physical materials.

I was expecting this to be easy. like the following:

# I'm fine with raycasts, they work, dont wanna sit here and make "real" raycast code!
func doRayCast(here to there):
	yadda yadda does raycast,
	return raycast_data

# then in process
func _process(delta: float) -> void:
	var rayCastData = doRayCast(here to there)
	var physMatHit = rayCastData.get_physical_material_hit
	if physMatHit == "physmat_metal":
		# say CLAinggggggggGGGggGGG

or, like so:

@export var char_body : CharacterBody3D

# then in process
func _process(delta: float) -> void:
	var physTouch = char_body.get_collider.get_physical_material_id()
	if physTouch == "physmat_metal":
		# say CLAingggggggg

You know… why not?

Anyone know how to do this?

Hi.
wouldn’t this be just …

… not tested