So im tryna make a katyusha type of thing and I have a system where it launches the missile and calculates the distance but the rotation has to be correct and im wondering how / if I can use lookVector or something else to turn the missle / missle holders towards the right direction.
(pretend that there is actually a launching thing connected to the base)
here is a video (without any turning: roblox pc crashing rocket barrage - YouTube)
I cloned the missle and made it go up so that if it tries to move sideways, it doesn’t bump into other missiles. Is there also a way to make the missiles face the way its going? Here is the code:
local filter = OverlapParams.new()
filter.FilterType = Enum.RaycastFilterType.Blacklist
filter.FilterDescendantsInstances = { workspace.Model:GetDescendants() }
while wait(.1) do
for i,v in pairs(script.Parent:GetChildren()) do
if v.Name == "Missile" then
local pos1 = v.Position
local pos2 = workspace.Part.Position + Vector3.new(math.random(-500,500),0,math.random(-500,500))
local direction = pos2-pos1
local duration = math.log(1.001+direction.Magnitude * 0.01)
local force = direction/duration + Vector3.new(0,workspace.Gravity* duration * 0.5,0)
print(duration)
local clone = v:Clone()
clone.Position = pos1
clone.CFrame = CFrame.lookAt(pos1,pos2) + Vector3.new(2,3,2)
clone.Parent = workspace
clone.Anchored = false
clone:ApplyImpulse(force*clone.Mass)
clone:SetNetworkOwner(nil)
task.spawn(function()
wait(1)
clone.Touched:Connect(function()
local exp = Instance.new("Explosion")
exp.Parent = workspace
exp.Position = clone.Position
exp.BlastRadius = 150
exp.BlastPressure = 15000
clone:Destroy()
wait(0.2)
exp:Destroy()
end)
end)
wait(0.05)
end
end
end