Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to make a Missile follow a path?

Asked by 5 years ago

I am trying to make a nuclear missile that follow a path that is modeled like the projectile equation: h(t) = 16^2+vt+h. I also want the missile's orientation to follow the path as well. I have used a script found here: scriptinghelpers.org/blog/modeling-a-projectiles-motion The problem is that I can't really mess with how high the projectile goes without sending the projectile into space or completely missing the target.

local t = 1;
local mouse = game.Players.LocalPlayer:GetMouse();
local hrp = game.Players.LocalPlayer.CharacterAdded:Wait():WaitForChild("HumanoidRootPart");
local bball = script.Parent:WaitForChild("Handle");

mouse.Button1Down:Connect(function()
    local g = Vector3.new(0, -game.Workspace.Gravity, 0);
    local x0 = hrp.CFrame * Vector3.new(0, 2, -2)

    -- calculate the v0 needed to reach mouse.Hit.p
    local v0 = (mouse.Hit.p - x0 - 0.5*g*t*t)/t;

    -- have the ball travel that path
    local c = bball:Clone();
    c.Velocity = v0;
    c.CFrame = CFrame.new(x0);
    c.CanCollide = true;
    c.Parent = game.Workspace;
end)

It would be helpful to me if the variables included: Target Position and Speed as well as the recommended speed to go over 2000 studs

0
99% sure this is a troll. and this isn't your code. fistter1 88 — 5y
0
You are right it isn't my code I linked where I got the script in the question TheWiseAndGreat 50 — 5y
0
It is an arc projectile as what i say cherrythetree 130 — 5y

Answer this question