Hello, I am trying to make it so the circle moves in a smooth lerp way toward the enemy Tower. Here below is an example I want it to be like:
And here below is my attempt and code:
Code:
local unitCircle = unit:FindFirstChild("EnemyAOE")
local currentCFrame = nil
if closestEnemy then
local unitPosition = unit.PrimaryPart.Position
local enemyPosition = closestEnemy.PrimaryPart.Position
local direction = (enemyPosition - unitPosition).Unit
local targetPositionCFrame = closestEnemy:FindFirstChild("Left Leg").CFrame
currentCFrame = currentCFrame and currentCFrame:Lerp(targetPositionCFrame, 0.17) or targetPositionCFrame
unit:SetPrimaryPartCFrame(CFrame.lookAt(unitPosition, unitPosition + direction))
unitCircle.CFrame = currentCFrame
end
Just to clear things up, there is a part in the middle of the aoe circle and an attachment to it so Im using that to move the unitCircle
As you can see, compared to my attempt, the example I wanted it to be like was a lot smoother and the circle didn’t instantly teleport to the desired towers position. For some reason my circle teleports but doesn’t go to the position of the enemy tower in a smooth way. I tried using lerp however it did not work.
Does anyone know how to make it like the first example?