Skip to content

Commit

Permalink
Updated _play_by_material to use interaction_type
Browse files Browse the repository at this point in the history
Updated _play_by_material to use interaction_type to comply with the _play_interaction function
  • Loading branch information
niefia committed Sep 1, 2024
1 parent b5a9163 commit 4afb1dc
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ func _play_interaction(interaction_type: String):
if interaction_type == "footstep":
if _play_by_footstep_surface(result.collider):
return
elif _play_by_material(result.collider, footstep_material_library, generic_fallback_footstep_profile):
elif _play_by_material(result.collider, footstep_material_library, generic_fallback_footstep_profile, interaction_type):
return
elif interaction_type == "landing":
if _play_by_landing_surface(result.collider):
return
elif _play_by_material(result.collider, landing_material_library, generic_fallback_landing_profile):
elif _play_by_material(result.collider, landing_material_library, generic_fallback_landing_profile, interaction_type):
return

func _play_by_footstep_surface(collider : Node3D) -> bool:
Expand All @@ -57,14 +57,19 @@ func _play_by_footstep_surface(collider : Node3D) -> bool:
func _play_by_landing_surface(collider: Node3D) -> bool:
return _play_by_footstep_surface(collider)

func _play_by_material(collider: Node3D, material_library: FootstepMaterialLibrary, fallback_profile: AudioStreamRandomizer) -> bool:
func _play_by_material(collider: Node3D, material_library: FootstepMaterialLibrary, fallback_profile: AudioStreamRandomizer, interaction_type: String) -> bool:
if material_library:
#find surface material
var material: Material = _get_surface_material(collider)
#if a material was found
if material:
#get a profile from our library
var profile: AudioStreamRandomizer = material_library.get_footstep_profile_by_material(material)
var profile: AudioStreamRandomizer
if interaction_type == "footstep":
profile = material_library.get_footstep_profile_by_material(material)
elif interaction_type == "landing":
profile = material_library.get_landing_profile_by_material(material)

#found profile, use it
if profile:
_play_footstep(profile)
Expand Down

0 comments on commit 4afb1dc

Please sign in to comment.