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

How to make a projectile's motion concave upwards?

Asked by
Nikkulaos 229 Moderation Voter
5 years ago
Edited 5 years ago

Its hard to explain as im rusty in algebra, but i got this script where it has a projectile move in a curved slope (from your humanoidrootpart to your mouses position) and it has a negative acceleration (where it concaves down).

local p = game.Players.LocalPlayer
local m = p:GetMouse()
repeat wait() until p.Character
local c = p.Character
local enabled = true
local t = 1;
local hrp = c:WaitForChild("HumanoidRootPart");
local bball = workspace.Hm;

m.Button1Down:Connect(function()
    local g = Vector3.new(0, -game.Workspace.Gravity, 0);
    local x0 = hrp.CFrame * Vector3.new(0, 2, -2)
    local mp = m.Hit.p--+Vector3.new(0,15,0)
    -- calculate the v0 needed to reach mouse.Hit.p
    local v0 = (mp - x0 - 0.5*g*t*t)/1;

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

What i am trying to do though, is make the slope has a postive acceleration, so that the slope's curve concaves upwards instead, starting as a decreasing slope and ending as an increasing slope when it reaches the destination.. Kinda like this: https://gyazo.com/48e64596375a2505968596c03583230c?token=417006b3cc7e1465d476fc20ae150d70

I have tried doing things, like setting the Gravity value to positive, and messing with the numbers and making them negatives/positives, higher/lower, etc. The closest i have gotten was setting the gravity to positive and making the destination 15 units higher, but the part just concaves downwards and does not appear again.

Anything will help!

Thanks!

0
Use variable names that are relevant and make sense. User#21908 42 — 5y
0
local v0 = (mp - x0 + 0.5*g*t*t)/1; brok4d 77 — 5y
0
@gulllet Thats where i started. Ill just look more into it i guess Nikkulaos 229 — 5y
View all comments (3 more)
0
@Phlegethon5778 I got most of them variables from a given script on this website, so argue with the dude that uploaded the original not me please. Also, its not even the variables that are the problem Nikkulaos 229 — 5y
0
@brok4d I tried that and got this result: https://gyazo.com/2608d5754a68adcae874c797e8989f10 Nikkulaos 229 — 5y
0
This is with my original script: https://gyazo.com/f4ce1c71b822807d712ad70532f123e7 Nikkulaos 229 — 5y

Answer this question