Roblox · Дополнительное
Наступил на площадку — тебя выстреливает по дуге точно в отмеченную точку, например на крышу или соседний остров. Время полёта задаётся в настройках.
Синим — что нужно создать.
Workspace └─ Launcher (Model) ├─ Pad (Part) — площадка; внутри Sound «Launch» ├─ Target (Part) — точка приземления: прозрачная, CanCollide выкл. ├─ Configuration (Configuration) — FlightTime └─ LauncherServer (Script)
Где: Workspace → Launcher · Script
Зачем: Бросок по дуге в точку Target.
-- удаление по таймеру
local Debris = game:GetService("Debris")
-- пушка
local model = script.Parent
-- площадка
local pad = model:WaitForChild("Pad")
-- куда лететь
local target = model:WaitForChild("Target")
-- настройки
local config = model:WaitForChild("Configuration")
-- кого недавно запустили
local recent = setmetatable({}, {__mode = "k"})
-- на площадку наступили
pad.Touched:Connect(function(otherPart)
-- модель
local character = otherPart.Parent
-- живая?
local humanoid = character:FindFirstChildOfClass("Humanoid")
-- центр
local root = character:FindFirstChild("HumanoidRootPart")
-- не живая
if not humanoid or not root or humanoid.Health <= 0 then return end
-- только что запустили
if os.clock() - (recent[character] or 0) < 1 then return end
-- запоминаем
recent[character] = os.clock()
-- секунд полёта
local t = config.FlightTime.Value
-- гравитация
local g = Vector3.new(0, -workspace.Gravity, 0)
-- формула броска: прилетим точно в Target
local velocity = (target.Position - root.Position - 0.5 * g * t * t) / t
-- точка толчка
local attachment = Instance.new("Attachment")
-- в центр
attachment.Parent = root
-- выстрел
local push = Instance.new("LinearVelocity")
-- куда приложен
push.Attachment0 = attachment
-- без ограничения силы
push.MaxForce = math.huge
-- нужная скорость
push.VectorVelocity = velocity
-- толкаем
push.Parent = root
-- толчок мгновенный — дальше летит сам
Debris:AddItem(push, 0.05)
-- точку тоже
Debris:AddItem(attachment, 0.05)
-- звук
local sound = pad:FindFirstChild("Launch")
-- бум
if sound then sound:Play() end
-- конец обработчика
end)Запусти Play (или Run) и убедись: