I want to make this character jump in a arc to the enemy tile, but for some reason it slows down at the end.
Video
i tried searching up but nothing really helped.
If there’s any way to fix this, i’d be happy to hear more about it.
The code:
local replicatedStorage = game:GetService('ReplicatedStorage')
local tweenService = game:GetService('TweenService')
local events = replicatedStorage:WaitForChild('Events')
local assets = replicatedStorage:WaitForChild('Assets')
local function quadraticSupport(p0, p1, p2, t)
return p0:Lerp(p1, t), p1:Lerp(p2, t)
end
return function(unit:Model, enemy:Model)
local primaryPart = unit.PrimaryPart
local E_primaryPart = enemy.PrimaryPart
local originalCFrame = primaryPart.CFrame
--local lookAt = tweenService:Create(primaryPart, TweenInfo.new(0.2, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut), {CFrame = CFrame.lookAt(primaryPart.Position, Vector3.new(E_primaryPart.Position.X, primaryPart.Position.Y, E_primaryPart.Position.Z))})
--lookAt:Play()
--local attackSfx = primaryPart:WaitForChild('SFX').Attack:GetChildren()[math.random(1, #primaryPart:WaitForChild('SFX').Attack:GetChildren())]
--attackSfx:Play()
local middle = (primaryPart.Position:Lerp(E_primaryPart.Position, 0.5)) + Vector3.new(0, 7, 0)
task.wait(1.6)
for t = 0, 1, 1/40 do
local p0, p1 = quadraticSupport(primaryPart.Position, middle, E_primaryPart.Position, t)
primaryPart.CFrame = CFrame.new(p0:Lerp(p1, t))
task.wait(0.01/60)
end
--task.delay(1, function()
-- local lookAt2 = tweenService:Create(primaryPart, TweenInfo.new(0.2, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut), {CFrame = originalCFrame})
-- lookAt2:Play()
--end)
enemy.PrimaryPart.RootAttachment.DMGTaken.Enabled = true task.delay(0.2, function() enemy.PrimaryPart.RootAttachment.DMGTaken.Enabled = false end)
end