(BodyForce) Wall jumper is very inconsistent

Hello!

I’m working on a wall jump system which is generally going well, except for some reason, it is very inconsistent on the part where the player jumps off.

This is how it looks so far:

The issue I’m having is that if you record the distance the player jumps from the wall, it varies so much, usually between 5 and 10 studs but sometimes exceeding 10:

Is there any way I can make it more consistent?

Here’s the part of the script that sends the player in the direction of their torso:

					humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
					local posHit = humanoidRootPart.Position
					playWallJumper()
					userInputService.JumpRequest:Wait()
					print('jr')
					humanoidRootPart.Anchored = false
					torso.Anchored = false
					humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, true)
					local bodyForce = Instance.new('BodyForce')
					humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
					bodyForce.Force = humanoidRootPart.CFrame.LookVector * 11000
					bodyForce.Parent = humanoidRootPart
					task.wait(0.05)
					bodyForce:Destroy()
					isInWall = false
					local newState
					repeat newState = humanoid.StateChanged:Wait() until newState == Enum.HumanoidStateType.Landed
					print('Distance: ', (humanoidRootPart.Position - Vector3.new(posHit.X, humanoidRootPart.Position.Y, posHit.Z)).Magnitude)

Is your problem that it pushes the player at different speeds every time? If so, I think this should fix it:
Change “humanoidRootPart.CFrame.LookVector” to “humanoidRootPart.CFrame.LookVector.Unit”

local bodyForce = Instance.new('BodyForce')
humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
bodyForce.Force = humanoidRootPart.CFrame.LookVector.Unit * 11000
bodyForce.Parent = humanoidRootPart

LookVectors are unit vectors already, you don’t have to use .Unit.

Maybe try using ApplyImpulse instead of a very quick body force? The problem might be that the acceleration is acting for 2-3 physics updates, and that variation is causing the differences in each jump?

(Heartbeat is about 1/40, force accelerates mass every heartbeat, 0.05 is time force acts, 0.05 is about 2 heartbeats but might misalign with the heartbeat cycles)

Code example:

local velocityChangeScalar = 20 -- Example value
local humanoidRootPart -- Set to HRP

humanoidRootPart:ApplyImpulse(humanoidRootPart.AssemblyMass * humanoidRootPart.CFrame.LookVector * velocityChangeScale)
humanoidRootPart.CFrame.LookVector * 11000

Have you tried toying around with this 11000 value?

I think this might be what I’m looking for, thanks! I’m gonna play around with it and see if I can get it to work properly since it seems to be more touchy than a BodyForce.

@Forummer, yeah I’ve tried many values ranging between like 1000 and 1 million and it seems to produce the same issue.

1 Like

Update, it’s perfect! velocityChangeScale at 50 seems to give the best result, thank you so much!

1 Like