Hello everyone, I am currently working on a Dash System using align position because it seems it’s the most stable and the only constraint, I have found that can do what Im envisioning it to be.
but I have met a problem, the align position curves before reaching the end on some angles, I am using move direction to get the direction to where the player will dash to. I have included a clip on what Im talking about and the source code for it.
any help is greatly appreciated!
local character = script.Parent
local humanoid: Humanoid = character.Humanoid
local attachment = Instance.new("Attachment")
attachment.Parent = character.HumanoidRootPart
local function dash()
local hrp: BasePart = character.HumanoidRootPart
local movDir = humanoid.MoveDirection.Magnitude > 0 and humanoid.MoveDirection.Unit or hrp.CFrame.LookVector
local alignPos = Instance.new("AlignPosition")
alignPos.Mode = Enum.PositionAlignmentMode.OneAttachment
alignPos.ApplyAtCenterOfMass = true
alignPos.Attachment0 = attachment
alignPos.ForceRelativeTo = Enum.ActuatorRelativeTo.World
alignPos.ForceLimitMode = Enum.ForceLimitMode.PerAxis
alignPos.MaxAxesForce = Vector3.new(10000000, 0, 10000000) * hrp.AssemblyMass
alignPos.MaxVelocity = 50
alignPos.Parent = hrp
alignPos.ReactionForceEnabled = false
alignPos.Responsiveness = math.huge
local converted = Vector3.new(movDir.X, 0, movDir.Z)
local goal = (hrp.CFrame + (converted * 20)).Position
local part = Instance.new("Part")
part.Position = goal
part.Size = Vector3.one
part.CanCollide = false
part.Color = Color3.fromRGB(255,0,0)
part.Anchored = true
part.Parent = workspace
print(movDir)
print(converted)
alignPos.Position = goal
alignPos.Parent = hrp
game:GetService("Debris"):AddItem(alignPos, .25)
end
game:GetService("UserInputService").InputBegan:Connect(function(input: InputObject, gameProcessedEvent: boolean)
if input.KeyCode == Enum.KeyCode.Q then
dash()
end
end)