Smoothly moving the player's character to a fixed location infront with a fixed speed

I’m currently making a rolling animation for my character. When rolling, the player will move towards a location in front of them over the duration of the animation. I currently use BodyMovers but I am having a hard time adjusting the forces to accomplish the goal within the animation duration. I want the speed to be constant (if the animation still plays but the character has reached its end position, keep the character in place). Using BodyMovers also causes the character to launch aimlessly when hitting a wall.

function ActionService:Tumble()
	if ActionService.InAction or ActionService.ForbiddenPoses[Modules.AnimationService.CurrentPose]
	or not ActionService.Armed then
		return
	end

	--Raycast forwards to find end location.
	local Raycast = Ray.new(Modules.CharacterService.HRP.Position, Modules.CharacterService.HRP.CFrame.LookVector * ActionService.TumbleLength)
	local _, Position = workspace:FindPartOnRay(Raycast, Modules.CharacterService.Character)
	
	local BodyPosition = Instance.new("BodyPosition")
	BodyPosition.Position = Position
	BodyPosition.MaxForce = Vector3.new(10000,10000,10000)
	BodyPosition.D = 1
	
	Modules.AnimationService:PlayAnimation("Tumble", false)
	
	Modules.AnimationService.StateConnections.Tumble = Modules.AnimationService.SpecialPlayingAnimation.KeyframeReached:Connect(function(Keyframe)
		if Keyframe == "Started" then
			ActionService.InAction = true
			BodyPosition.Parent = Modules.CharacterService.HRP
			
			
			Modules.CharacterService.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
			Modules.CharacterService.Humanoid.WalkSpeed = 0
					
		elseif Keyframe == "Ended" then
			ActionService.InAction = false
			BodyPosition:Destroy()
			
			Modules.CharacterService.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, true)
			Modules.CharacterService.Humanoid.WalkSpeed = 14
			
			Modules.AnimationService.StateConnections.Tumble:Disconnect()
			Modules.AnimationService.StateConnections.Tumble = nil
		end
	end)
end


why not use the SetPrimaryPartCFrame function along with the HumanoidRootPart’s look vector?

It’s close to what I want, but the RootPart always faces towards the origin.

function ActionService:Tumble()
	if ActionService.InAction or ActionService.ForbiddenPoses[Modules.AnimationService.CurrentPose]
	or not ActionService.Armed then
		return
	end
	

	local Raycast = Ray.new(Modules.CharacterService.HRP.Position, Modules.CharacterService.HRP.CFrame.LookVector * ActionService.TumbleLength)
	local _, Position = workspace:FindPartOnRay(Raycast, Modules.CharacterService.Character)
	
	local LookGoal = Modules.CharacterService.HRP.CFrame.LookVector * Modules.VectorFunctions:GetMagnitude(Modules.CharacterService.HRP.Position, Position)

	local TempValue = Instance.new("Vector3Value")
	TempValue.Value = Modules.CharacterService.HRP.Position
	
	local Changed
	local CFrameTween
	
	
	Modules.AnimationService:PlayAnimation("Tumble", false)
	
	Modules.AnimationService.StateConnections.Tumble = Modules.AnimationService.SpecialPlayingAnimation.KeyframeReached:Connect(function(Keyframe)
		if Keyframe == "Started" then
			ActionService.InAction = true
			
			Modules.CharacterService.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
			Modules.CharacterService.Humanoid.WalkSpeed = 0
			
			CFrameTween = MainFramework.TweenService:Create(TempValue, TweenInfo.new(Modules.AnimationService.SpecialPlayingAnimation.Length), {Value = Position})
			CFrameTween:Play()
			
			Changed = TempValue.Changed:Connect(function()
				Modules.CharacterService.Character:SetPrimaryPartCFrame(CFrame.new(TempValue.Value, LookGoal))
			end)
				
		elseif Keyframe == "Ended" then
			ActionService.InAction = false	
			
			Changed:Disconnect()
			CFrameTween:Cancel()
			
			
			Modules.CharacterService.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, true)
			Modules.CharacterService.Humanoid.WalkSpeed = 14
			
			Modules.AnimationService.StateConnections.Tumble:Disconnect()
			Modules.AnimationService.StateConnections.Tumble = nil
		end
	end)
end

How are you planning on moving the player? Using velocity or a raycast ahead of them to know where the final position will be?

If you use velocity, you just need to get the distance of the roll. Then, you calculate the speed by dividing distance / length of animation. Then, you set the player’s velocity to the resulting speed every frame for the duration of the animation.

If you use a raycast, you can simply lerp the start position of the torso (or any part that is convenient) to the end position over the duration of the animation. With a percentage based off of the animation’s length.

try using the head instead then

That won’t work because the head never faces the front in the first place.

did you try using other body parts like the chest?

–edited
I mean torso

Every other part except the HumanoidRootPart does not look at the front because of the animation.

well you could try creating a Cframe from the humanoid root part cframe and then you rotate the Cframe on the y axis so its facing the same direction as the torso, like this for example

local Cframe = Character.PrimaryPart.CFrame
Cframe = Cframe*CFrame.Angles(0,math.rad(Character.Torso.Orientation.Y),0)
--then you use this Cframe's look vector