Custom Movement System

I’m trying to make a custom movement system to accompany custom gravity and overall just more complex and customizable movement. I’m using body forces and while it seems to work sufficiently enough for a demo it does this weird thing once the gravity force is applied in which it seems to throw my player so far out that the game glitches and pauses briefly unable to keep up with the distance the character has travelled, before coming right back to where they are I assume by the physics engine not agreeing.

TLDR: I would like to know why my vectorforce is flinging and glitching my game even after it is turned off

(The position of the character is changed btw I checked)

1 Like

Can you upload the accompanying code for driving the VectorForce?

local gravity = script.Gravity

gravity.Parent = hrp
gravity.Attachment0 = hrp.RootAttachment
gravity.Force = Vector3.new(0,math.huge*-1,0)

gravity.Enabled = true
hum.StateChanged:Connect(function()
	local state = hum:GetState()
	if state == Enum.HumanoidStateType.Freefall or state == Enum.HumanoidStateType.Jumping then
		gravity.Enabled = true
	else
		gravity.Enabled = false
	end
	print(gravity.Enabled)
end)

local walker = script.Walker

walker.Parent = hrp
walker.MaxForce = math.huge
walker.Attachment0 = hrp.RootAttachment

local jumper = script.Jumper

jumper.MaxForce = math.huge
jumper.Parent = hrp
jumper.Attachment0 = hrp.RootAttachment

local UIS = game:GetService("UserInputService")

local MovementKeys = {"W", "A", "S", "D", "Space"}

local Dirs = {
	Vector3.new(0,0,25), --W
	Vector3.new(-25,0,0), --A
	Vector3.new(0,0,-25), --S
	Vector3.new(25,0,0), --D
	Vector3.new(0,25,0) --Space
}

UIS.InputBegan:Connect(function(input, GPE)
	if not GPE then
		for i, v in pairs(MovementKeys) do
			if input.KeyCode == Enum.KeyCode[v] then
				if input.KeyCode == Enum.KeyCode.Space then		
				else
					walker.VectorVelocity = walker.VectorVelocity + Dirs[i]
				end
				
			end
		end
	end
end)

UIS.InputEnded:Connect(function(input, GPE)
	if not GPE then
		for i, v in pairs(MovementKeys) do
			if input.KeyCode == Enum.KeyCode[v] then
				if input.KeyCode ~= Enum.KeyCode.Space then
					walker.VectorVelocity = walker.VectorVelocity - Dirs[i]
					
				end
			end
		end
	end
end)

its very rough rn I’m jus trying to get a grasp for how to go about this