this is a continuation of a previous thread:
Since that previous post I have been able to make the Homing
missiles correctly rotate towards a moving target by just having their model’s MovementPoint
be rotated.
The problem isn’t quite over yet however since the Non-Homing
missiles still aren’t fixed and I’ve hit more dead-ends trying to find a way to fix them.
As it stands right now, they will no longer be fired at an angle and move completely vertical, instead they will stay horizontal but at a flat angle with no changes made to it.
The current code for them is very similar to this, with a slight bit cut out for simplicity’s sake
local TweenS = game:GetService("TweenService")
local NotEnded = true
script.Parent.Event.Event:Connect(function(Target)
local Thing1 = (script.Parent.MovementPoint.Position - Target).Magnitude
local Thing2 = (Thing1 / 0.5) / 100
local TweenInf = TweenInfo.new(Thing2, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0)
local Finish = {CFrame = CFrame.new(Target)}
local Tween = TweenS:Create(script.Parent.MovementPoint, TweenInf, Finish)
Tween:Play()
wait(Thing2)
NotEnded = false
end)
script.Parent.Event.Event:Connect(function(Target)
print("test thing")
while NotEnded == true do wait()
script.Parent.MovementPoint.CFrame = CFrame.new(script.Parent.MovementPoint.Position, Vector3.new(Target.X, Target.Y, Target.Z))
end
end)
variables are almost identical to last time, you can check the previous post for context.
A few things to note from the previous post, the missiles are moved using a part called the MovementPoint
since they are built in a way of which that Position
changes won’t cut it, thus CFrame
is needed instead which can cause problems with getting CFrame.lookAt()
or equivalents to work properly.
If I can get the missiles to not only rotate towards the target but stay rotated towards the target then that would solve my issue, help here would be greatly appreciated.