Heya!
I’ve recently been trying to make a projectile for a tower in my tower defense game.
I want the projectile (in this case a missile) to always face towards the target so it looks like it’s actually flying towards it.
My current code looks like this:
new:PivotTo(CFrame.lookAt(cframe.Position, enemyModel.PrimaryPart.Position))
new.Parent = workspace.CurrentCamera
local distance : number = (cframe.Position - enemyModel.PrimaryPart.CFrame.Position).Magnitude
local travelTime : number = distance / projectileSpeed
local newCFrame = enemyModel:GetPivot() + new.PrimaryPart.CFrame.LookVector
local info = TweenInfo.new(travelTime, Enum.EasingStyle.Linear)
local travelTween = tweenService:Create(new.PrimaryPart, info, {CFrame = newCFrame})
travelTween:Play()
“New” being the cloned projectile (model).
But for some reason it resulted in weird stuff like in the image:
As you can see, the missiles start to point up weirdly near the end of their lifetime.
How can I go about fixing it?
Thanks!!