Sped up animation becomes choppy and causes inconsistent hits

I’m trying to change the speed of my animation (Blender animation) in Roblox, while still having accurate frames.

The issue is that the animation becomes choppy when I increase the speed. This causes the hits to become inconsistent. I’m not sure if I should change the animation or the hit detection.

Higher speed: (kind of difficult to see because of the video quality, but the sword movement is choppy and inconsistent)

Lower speed:

The solutions I’ve tried so far are:
Tried different ways of hit detection like using normal rays and GetPartBoundsInBox and also removing the hit detection.
Increased the frames in Blender.
Changed the framerate in Blender.
Increased the priority to action4 and changed the weight.
Changed easing and interpolation modes in Blender.

I’m also using a custom motor6d as the handle attachment, which the animation uses to move the handle.

Usage of animation:

meleeTool.Activated:Connect(function()
	if clientState:IsActive("Attacking") then return end
	clientState:EnableState("Attacking")

	if attack and attackW then
		local windupAnim = animator:LoadAnimation(attackW)
		windupAnim:Play(0.5, 2, meleeData.Info.WindupSpeed)
		windupAnim.Stopped:Wait()
		
		local attackAnim = animator:LoadAnimation(attack)
		attackAnim:Play(0.5, 2, meleeData.Info.Speed)
		Detection.MeleeBlockCast(meleeTool, attackAnim)
	end

	clientState:DisableState("Attacking")
end)

Hit detection:

function Detection.MeleeBlockCast(meleeTool, anim)
	local hitParts = {}
	local preventHit = {}
	local hitbox = meleeTool.Handle:FindFirstChild("Hitbox")
	
	if hitbox then
		local params = RaycastParams.new()
		params.FilterType = Enum.RaycastFilterType.Exclude
		params.FilterDescendantsInstances = {meleeTool.Parent}

		local cast
		cast = RunService.RenderStepped:Connect(function()
			if not anim.IsPlaying then cast:Disconnect() return end

			local result = workspace:Blockcast(hitbox.CFrame, hitbox.Size, hitbox.CFrame.LookVector, params)
			if result then
				local hitPart = result.Instance
				local hitPlayer = hitPart.Parent
				local humanoid = hitPlayer:FindFirstChild("Humanoid")
				
				if hitPlayer:IsA("Model") and humanoid and not preventHit[hitPlayer] then
					preventHit[hitPlayer] = true
					table.insert(hitParts, hitPart)
					print('hit', hitPlayer.Name, hitPart.Name)
					humanoid:TakeDamage(10)
				end
			end
		end)
		anim.Stopped:Wait()
		return hitParts
	end
end
1 Like