Align Position on Character Curves Sometimes

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!

Clip!

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)
2 Likes

The clip won’t load for me. Might just be my internet or site blocked in my location

just noticed it, it should be fixed now! : )

What exactly is the problem? Is it when you jump you slowly go back to the intended path?

Yeah so sometimes when going on a specific direction or angle when dashing it kinda curves before going back to the intended direction, its does not always happen as seen from the first few seconds of the clip

I would just use AssemblyLinearVelocity on the HumanoidRootPart instead of align position. This would avoid this problem completley.

Im not on my pc currently so I cant test at the moment, but how do you combat the friction that the character has? like for example standing and jumping gives a different result mainly due to the lack of friction when jumping

I have done this before, don’t remember how I fixed that problem tho. Might check tomorrow.

1 Like