Need help with hover car

Hey! While attempting to create the lift mechanic of my hover-car, I stumbled upon an annoying jitter effect which would be present no matter how I tweaked my damping coefficient. The type of force used is a vector force.

Here is a video of it:
https://gyazo.com/f56dfbd699d7e96bf07af9008c47086d

Code used:

    function Movement:_handleLift()
    	for _, v in ipairs(self._liftForces) do
    		-- Find out the height of the vehicle:
    		local liftPoint = v.Parent
    		local liftPointPosition = liftPoint.Position
    		local raycastResult = workspace:Raycast(liftPointPosition, self._raycastDirection)
    		
    		if not raycastResult then
    			-- This lift point is above the lift height and therefore no force is nessecary.
    			v.Force = Vector3.new(0,0,0)
    			continue -- Skip to the next point
    		end
    		
    		local heightOffGround = (liftPointPosition - raycastResult.Position).Y
    		
    		-- Apply the force:
    		local dampingForce = -1000 * v.Parent.Velocity
    		local direction = liftPoint.CFrame.UpVector
    		local force = Vector3.new(0, workspace.Gravity * self._mass + self._liftForce, 0) * direction + dampingForce
    		
    		v.Force = force
    	end
    end

Any solutions are appreciated.

The old BodyMovers are depreciated (though they can be useful), so maybe try using some kind of constraint.

Also, this is just an idea, but maybe a good way to calculate damping would be to calculate the distance between the vehicle and the ground. I’m thinking that something weird could be going on there. Be sure to do some good research with what you’re trying to do.

Also, I see that you multiply force by direction, but that won’t do anything since force only affects the Y axis with how you set it up. Maybe that could be another issue causing this.

1 Like