i’m on my journey of creating a custom movement system for my game, and i’ve finally figured out how to get the player to move one direction when i press W, but there’s a few problems that need fixing.
right now, i’m trying to keep it simple. just move forward. it works, but…
- My alignposition doesn’t move along the camera’s Y axis
- My character doesn’t fall
- The AlignPosition eases out when i stop. I’ve tried fixing this with enabling RigidityEnabled but now i can’t control the speed.
- After some time, the AlignPosition stops updating for some reason?
my script:
--variables
local run_service = game:GetService("RunService")
local userinput_service = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character.Humanoid
local humanoid_rootpart = character.PrimaryPart
local current_camera = game.Workspace.CurrentCamera
local rootpart_attachment = Instance.new("Attachment")
rootpart_attachment.Parent = humanoid_rootpart
rootpart_attachment.Name = "AlignPositionAttachment"
AlignPos = Instance.new("AlignPosition")
AlignPos.Parent = humanoid_rootpart
AlignPos.Mode = Enum.PositionAlignmentMode.OneAttachment
AlignPos.MaxForce = 10e38
AlignPos.Attachment0 = rootpart_attachment
AlignPos.Position = humanoid_rootpart.Position
local isWalking = false
--main
userinput_service.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.W then
isWalking = true
while isWalking == true do
run_service.RenderStepped:Wait()
AlignPos.Position = humanoid_rootpart.Position + Vector3.new(0,0,5)
end
end
end)
userinput_service.InputEnded:Connect(function()
isWalking = false
end)
i’ve tried fixing a few of these myself but i can’t figure out how to do it. any help would be appreciated. thanks.