Consistent method to detect jumping, falling, and landing?

Howdy. I am currently trying to set up some sounds for when a player moves - footsteps, jumping, landing, etc.

I’ve been having trouble with jumping and landing specifically. My current method involves playing sounds based on the player’s humanoid state via StateChanged, but this has yielded inconsistent results. When bunnyhopping, the jumping sound will play during some (but not all) jumps, and similarly the landing sound will play sometimes (but not always) when you touch the ground.

I am also hoping to detect how far the player falls so that things like walking down stairs or slopes won’t trigger the landing sound, but I’m encountering the same issue here. I am using StateChanged to see when the player begins freefalling and check their initial altitude, except this seems very unreliable and the results do not match the actual distance of the fall.

Is there a way to accomplish this without using humanoid states or the RbxCharacterSounds script?

1 Like

Hm, I’ve made a footstep script before. It was a while ago, so I’ll have to look over it again.

Ah, here we go.

Here’s a rundown of what I do.

while humanoid.Parent do
	if humanoid.MoveDirection == Vector3.zero then 
		task.wait(); 
		continue 
	end
	
	task.wait((0.27 / ((humanoid.WalkSpeed / 16) * (humanoid.HipHeight / 2))) / 2)
	
	repeat
		humanoidRootPart[(humanoidRootPart:FindFirstChild(humanoid.FloorMaterial.Name) and humanoid.FloorMaterial.Name) or "Default"]:Play()
	until task.wait(0.27 / ((humanoid.WalkSpeed / 16) * (humanoid.HipHeight / 2))) and humanoid.MoveDirection == Vector3.zero
end

You can have this script if you want, it works for me.

I use a list of sounds based on the Humanoid.FloorMaterial value.

You can change player sounds with RbxCharacterSounds in StarterPlayerScripts when you play. You would copy over RbxCharacterSounds into StarterPlayerScripts while not in game.
image

Thank you, but footstep sounds aren’t the thing I’m having issues with. As mentioned in the post, I am currently focusing on jumping and landing.

Hm. Okay. There are many ways to check if the player is grounded, or in the air. You can use Humanoid:GetState(), or you can use Humanoid.FloorMaterial.

How does the script that handles footsteps work? Can you send it?

Unfortunately this won’t work for me; all of my sounds are based on the FloorMaterial that the player is on, and so I am using my own script to accommodate for that. I have already edited RbxCharacterSounds to mute all of the sounds it creates. Is there a method I could use besides that?

…Sorry if this comes off as rude, but did you even read the original post? I specifically stated that I am trying to find a solution that does not involve checking humanoid states; that was the original method I used, but it is giving me very inconsistent results.

Try using humanoid.FloorMaterial?

This doesn’t help with jump sounds, as it cannot distinguish between whether the player jumps or simply walks off a ledge.

This doesn’t help with landing sounds, as it does not give me any information regarding how far the player has fallen.

Do downwards raycasts that detect whether the player is grounded or not.

There is a Humanoid.Jumping I think. Here are some scenarios:

  • Player walks off a ledge. Detect with Humanoid.FloorMaterial and a falling sounds plays (if you want.)
  • Player lands on the ground. Detect with Humanoid.FloorMaterial and how long it was set to “Air” and/or check speed by getting the fall distance to determine speed with distance/time. Play a landing sound if long/fast enough fall.
  • Player jumps. Check with Humanoid.Jumping or Humanoid.FloorMaterial change or both. Play a jumping sound. Or check UserInputService.JumpRequest and check the Humanoid.FloorMaterial.