Hey guys, i want make nuke bomb and me need direct her in the direction she’s going
function lookat it works crookedly
Hey guys, i want make nuke bomb and me need direct her in the direction she’s going
function lookat it works crookedly
It is hard to say what you are aiming for. Do you want the nuke to look in the direction that it is travelling? I can’t obtain much information from what you’ve provided.
Yes i want so that the nuclear bomb is pointed in the direction in which it flies
I’m still unsure what you’re looking for, so I can’t give you the best solution. However, this will do just that:
function unitMeta:Nuke()
if self.unit.Name == "Nuke" and not self.IfTarget then
local startPos = self.unit:GetPivot().Position
local targetPos = self.Target
local center = (startPos + targetPos) / 2
local raisedCenter = Vector3.new(center.X, center.Y + 10, center.Z)
local Nuke = self.unit.Nuke
local duration = calculateTime(startPos, targetPos, self.unit.Stats.Speed.Value)
local last, ignore = Nuke.CFrame, false
Nuke:GetPropertyChangedSignal("CFrame"):Connect(function()
if (ignore) then return end
ignore = true
Nuke.CFrame = CFrame.lookAt(Nuke.CFrame.Position, last.Position)
ignore = false
last = Nuke.CFrame
end)
local TweenToCenter = tweenService:Create(Nuke, TweenInfo.new(duration / 5, Enum.EasingStyle.Linear, Enum.EasingDirection.In), {Position = raisedCenter})
TweenToCenter:Play()
TweenToCenter.Completed:Wait()
local TweenToTarget = tweenService:Create(Nuke, TweenInfo.new(duration / 8, Enum.EasingStyle.Linear, Enum.EasingDirection.Out), {Position = targetPos})
TweenToTarget:Play()
self.IfTarget = true
end
end
Replace
Nuke.CFrame = CFrame.lookAt(Nuke.CFrame.Position, last.Position)
with
Nuke.CFrame = CFrame.lookAt(Nuke.CFrame.Position, last.Position, Vector3.xAxis)
or, if it doesn’t work
Nuke.CFrame = CFrame.lookAt(Nuke.CFrame.Position, last.Position, Vector3.zAxis)
Instead of doing CFrame.lookAt, use CFrame.new instead
Example:
Nuke.CFrame = CFrame.lookAt(Nuke.CFrame.Position, last.Position)
should instead be:
Nuke.CFrame = CFrame.new(Nuke.CFrame.Position, last.Position)
Everything you need to do is pass the position and the lookat as the second arg,
Let’s say you want your Nuke to look towards Vector3.new(0,0,0) position. You would do sum like this
local newPosition = Nuke.CFrame.Position
local lookAtPosition = Vector3.new(0,0,0)
Nuke.CFrame = CFrame.new(newPosition, lookAtPosition)
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.