Play sound under certain conditions
Asked Answered
M

6

0

Hello, everyone!

A player jumps up onto a platform.
The player jumping up flies through the platform (collision is configured as One Way Collision )
When touching the platform, the sound of footsteps is configured, using collision signals.

Task:
How to make it so that the sound of footsteps is switched on not at the moment when the player flies through the platform, but when he lands on top of it after flying through it.

Thanks

Marxmarxian answered 6/12, 2023 at 21:12 Comment(0)
P
1

Marxmarxian When touching the platform, the sound of footsteps is configured, using collision signals.

Is the same signal emitted when the player flies through the platform, and when he lands on top of it?

How about checking the player's direction of movement? Play the sound when velocity.y > 0 (down) but not when velocity.y < 0 (up)?

Photophore answered 6/12, 2023 at 21:25 Comment(0)
M
0

Photophore
I just want the sound of landing on the platform. I haven't figured it out yet.
Is it possible to set the signal for landing only?

I get that the player has a double touch with collision. The first when he flies over the platform, the second when he lands. I need the second one.

Thanks for the hint with the direction of movement, only I have sounds are tied to the platform, apparently have to transfer to the node of the player.

Marxmarxian answered 6/12, 2023 at 22:3 Comment(0)
P
0

How exactly are you detecting the collision and playing the sound?

Photophore answered 6/12, 2023 at 22:8 Comment(0)
M
0

Photophore

In platform script:

func _on_footstep_sound_area_entered(area):
if area.name == "Foot_player":
if fplay != null:
fplay.play()

Marxmarxian answered 6/12, 2023 at 22:55 Comment(0)
P
0

You could check the player's velocity inside that function. I'm not sure that it would help, since it might be zero when the collision occurs.

Photophore answered 6/12, 2023 at 23:4 Comment(0)
M
0

Photophore

here's a reference, maybe it'll make more sense.

I was only able to upload the gif here

Marxmarxian answered 6/12, 2023 at 23:27 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.