Capsule jitters when moving with forces

I am trying to make a custom movement system using a LinearVelocity on a capsule mesh to move it around with the player’s inputs.

The problem is when the mesh is moved it jitters up and down slightly if it is moving fast enough.


I’ve tried some solutions like

  • removing friction entirely (setting Friction to 0 and FrictionWeight to 100)
  • removing elasticity (by setting Elasticity to 0 and ElasticityWeight to 100)
  • switching to a VectorForce instead of a LinearVelocity

Here are the CustomPhysicalProperties on the capsule if it helps:

Make something like a HipHeight like a Humanoid for the Entity. Then make the legs uncollidable

..and how exactly would i do that?

honestly not too sure how youd do it without constantly raycasting. I guess you can scratch my idea.

I want to solve your problem, because I am very familiar with roblox physics and bodymovers, and the character model, but the video won’t work for me. Could you try a different recorder? And send the model in the explorer.

Only reason I can think of why it’s jittering is because you aren’t applying a counteractive force to gravity.

It’s kind of like dragging your feet across rocky ground; you aren’t really pushing upwards, rather, you’re scraping the top of your feet. LinearVelocities usually solve this because they counteract all force to match the velocity you want, but it’s limited based on MaxForce.
If the mass of your collider multiplied by the velocity you’re currently going (Newton’s laws or something, F=ma) exceeds some combination of the velocity you wish to apply + the gravity (LinearVelocities handle applying mass I believe), you’ll just keep scraping against the ground.

So, two questions: what are you setting the VectorVelocity (or whichever VelocityContraintMode’s velocity you’re using) to, and what is the MaxForce? A small code snippet would also be appreciated.

The MaxAxesForce is 2500, 0, 2500
I dont really want to have to set the Y velocity because i dont wanna have to implement gravity as well

The code for setting the VectorVelocity isnt that special but here

The code inside the function that binded to render step

local char: Model? = self.char
local rootPart: BasePart? = self.rootPart
if not (char and rootPart) then return end

local inputVector = self.inputVector

local camCFrame = cam.CFrame
local _, camCFrameRotY = camCFrame:ToOrientation()

local alignOrientation: AlignOrientation = self.alignOrientation
alignOrientation.CFrame = CFrame.Angles(0, camCFrameRotY, 0)

local lookVec, rightVec = (camCFrame.LookVector * Vector3.new(1,0,1)).Unit, (camCFrame.RightVector * Vector3.new(1,0,1)).Unit
local vectorRelativeToCam = (-lookVec * inputVector.Z) + (rightVec * inputVector.X)
self.inputVectorRelToCam = vectorRelativeToCam

local stairHeight = self:_checkForStairStep()
if stairHeight then
	rootPart.CFrame += (vectorRelativeToCam * 0.2)
	--rootPart:ApplyImpulse(vectorRelativeToCam + Vector3.new(0, stairHeight, 0) * 50)
end

local isGrounded = self:_checkIsGrounded()
if self.jumpInput and isGrounded then
	self:Jump()
end

local moveVelocityForce: VectorForce? = self.moveVelocityForce
moveVelocityForce.VectorVelocity = vectorRelativeToCam * MOVE_SPEED

That is entirely where your issue lies.

You aren’t allowing the LinearVelocity to apply any force to the Y velocity, so you cannot counteract it at all. Your MaxAxesForce should be something like Vector3.new(2500, (Workspace.Gravity + math.abs(Velocity.Y)) * Mass, 2500) (though, adding velocity.Y like that probably isn’t the correct way to do it; I’m more-or-less saying “hey, account for gravity AND the current Y velocity”).

Though, I presume you would still want gravity to act upon your character controller when it isn’t grounded. So, you’d want to only include the Y component in MaxAxesForce when your character is touching a floor.

Also, as a sidenote, lookVec/rightVec are sometimes able to be undefined (div by 0). If you’re looking upwards or downwards at a 90 degree angle, the LookVector would be 0,1,0 or 0,-1,0, and you aren’t checking for that. You could also just utilize the “camCFrameRotY” (yaw) variable that you use, e.g.:

local lookX: number = math.sin(camCFrameRotY)
local lookZ: number = math.cos(camCFrameRotY)

local vectorRelativeToCam: vector = vector.normalize(vector.create(
    (-inputVector.Z * lookX) - (inputVector.X * lookZ),
    (inputVector.X * lookX) + (-inputVector.Z * lookZ)
))

You might have to swap a variable or two around, I was basing this off of my old character controller where I did trig like this