I know this is a late response and you and I actually talked about this specifically on twitter, but it seems worth it to answer this for anyone else who may stumble upon this question in the future.
There are two ways you can do that both of which do require a quadratic equation of some sort. You can use either matrices like I do in this video to solve for system of equations. Or you can use physics to solve for a function of time and position, which is also a quadratic equation.
The problem is both those equations don't work with vectors. So what you need to do is get two axis that you can use to multiply your equations values in to get the vector form. The x-axis is really easy to get, simply subtract do a vector subtraction and get the unit vector in the horizontal direction the projectile should be going. Recall though, you only want x and z components! The y-axis is also easy because you want only y components so you know your unit vector is going to be <0, 1, 0>.
With all that in mind:
01 | local mouse = game.Players.LocalPlayer:GetMouse(); |
02 | local character = game.Players.LocalPlayer.CharacterAdded:wait(); |
03 | local hrp = character:WaitForChild( "HumanoidRootPart" ); |
08 | local part = Instance.new( "Part" , game.Workspace); |
09 | part.CanCollide = false ; |
12 | local xaxis = (v - hrp.CFrame.p); |
13 | local yaxis = Vector 3. new( 0 , 1 , 0 ); |
15 | local sv = hrp.CFrame.p + hrp.CFrame.lookVector * 3 ; |
19 | local function curve(t) |
20 | return (grav/ 2 ) * t^ 2 + t * v 0 + x 0 ; |
23 | local tfinish = (-v 0 - math.sqrt(v 0 ^ 2 - 4 *(grav/ 2 )*x 0 ))/( 2 *(grav/ 2 )); |
26 | while (tick() - t) < = tfinish do |
27 | local dt = tick() - t; |
28 | part.CFrame = CFrame.new((sv + xaxis * dt/tfinish) + yaxis * curve(dt)); |
29 | game:GetService( "RunService" ).RenderStepped:wait(); |
33 | mouse.Button 1 Down:connect( function () |
It could use some smoothing over, but you get the idea hopefully