How do I stop player's character from bouncing after landing from a high height

Title describes this post, I’m trying to fix the problem of player’s bouncing when falling for a high height. Since my game has a lot of that, I’m trying to fix it.

1 Like

This topic isn’t my strong point but i guess you need to set the VectorForce of humanoidrootpart to zero

10th July 2023 edit: I was wrong, I confused VectorForce with AssemblyLinearVelocity. You should set it to zero upon player’s landing as @CJ_Oyer did below in post number 19 How do I stop player's character from bouncing after landing from a high height - #19 by CJ_Oyer

1 Like

I don’t know if this will work, I’m using VectorForce for a jet pack mechanic in my game.

1 Like

There’s also thing called BodyForce but it got “superseded by VectorForce”

1 Like

And how would I use it to negate the bouncing?

Why can’t you use the same thing for it btw

I think I could, I just don’t how I would stop the bouncing with it.

I think you should use FreeFalling event and when it gives you false then set the VectorForce to 0 (I see this event first time so sorry if i’m wrong)

2 Likes

Wouldn’t the player still bounce with the force set to 0?

All BodyParts are attached to HumanoidRootPart so you should set HumanoidRootPart’s VectorForce to zero (I guess)

1 Like

I’ll try this, I’ll let you know if it works.

Like I expected, it’s not working.

Can you send the code that you used?

Can’t be bothered, already deleted it.

LocalScript in StarterPlayerScripts

local player = game:GetService("Players").LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character and character:FindFirstChild("Humanoid")

humanoid.FreeFalling:Connect(function(bool)
    if not bool then
        -- set VectorForce
    end
end)

I tried using this which I thought should work, but didn’t seem to react fast enough to the player flinging:

humanoid.StateChanged:Connect(function(oldState, newState)
	if oldState == Enum.HumanoidStateType.Landed  and
		newState == Enum.HumanoidStateType.FallingDown then
		HRP.Anchored = true
		wait(0.1)
		HRP.Anchored = false
	end
end)

Really interested to hear if anybody has a solution to the bounce/fling problem

I still don’t understand how setting a VectorForce to 0 would stop the bouncing.

In shorter terms, you can’t.

Due to the way 3D game engines such as Roblox’s handle physics, you cannot stop bouncing using any form of Script. The only way to prevent this is to set all of the Players Body Parts to Massless = True.

However it doesn’t fully solve the problem. Falling from high heights with Massless turned on can cause other issues like the feet clipping through the terrain/part depending on width, however it doesn’t happen often and this is your best bet at achieving this effect.

You can make a script which for loops through the character when they first join the game. Falling from high heights with massless turned off* causes this bounce/fling effect, however turning on Massless for every body part in the players character object solves the issue (at least it does for me)

Just tested with a 1000 stud drop

1 Like

Sorry to bump this, however I did find a way around this issue to anyone in the future who is interested :+1:

Here’s how I solved it

local character --character, can grab from CharacterAdded signal / or placing script under character in StarterCharacter
local humanoid = character:WaitForChild("Humanoid")
local primaryPart = character:WaitForChild("HumanoidRootPart")

humanoid.StateChanged:Connect(function(oldState, newState)
	if newState.Name == "Landed" then
		-- cancel out existing velocity
		local velo = primaryPart.AssemblyLinearVelocity
		primaryPart.AssemblyLinearVelocity = velo*Vector3.new(1,0,1)

		-- get distance to ground
		local ray = Ray.new(primaryPart.Position, Vector3.new(0,-20,0))
		local hit, pos = game.Workspace:FindPartOnRay(ray, character)

		--apply ground hit position to character at hip height offset
		local hipHeight = humanoid.HipHeight
		local newPos = pos + Vector3.new(0,hipHeight,0)
		character:SetPrimaryPartCFrame(primaryPart.CFrame - primaryPart.Position + newPos)
	end
end)

The Process

For those who prefer english to lua, here’s what I did:

  1. On the client (since that needs a near instant response to look right), used the “Landed” state change humanoid signal to detect when they’re about to hit the ground
  2. Cancelled out the existing Y Axis velocity
  3. I originally thought this would be it, however apparently this event fires the frame before you’re actually contacting the ground, or possibly it bakes in your bounce position post hit. Either way, after doing this your character will stop a few meters above the ground then fall from there. To fix this, I simply immediately teleport the player to the ground
  4. To do this, I fire a raycast (admittedly using the deprecated and less performant, but also less tedious to implement, Ray.new method) that’s facing towards the ground. If anything is detected below the player within 20 units, that position is then used to teleport the player to that position, including the hip height offset so that it doesn’t get stuck in the ground.

The Result

Now to just play a superhero landing animation + cool shockwave fx :stuck_out_tongue:

Hope this helps!

24 Likes

That’s really nice. I got one question tho. What is AssemblyLinearVelocity? I tried looking many topics about this but I didn’t seem to understand the property of it and how it works? If any of you know what it is, would you mind explaining how it works?