Hello! I am currently scripting a football projectile using EgoMoose's open source code on projectiles. I am having trouble making the football point toward the correct direction while it travels in a parabola. This code currently makes the football point toward the target, however, the problem with this is that the football points straight up as it travels upward and then it points horizontally as it hits the target. What function would allow the football to point in the correct direction as it goes upward and downward?
local t = 1;
local mouse = game.Players.LocalPlayer:GetMouse();
local hrp = game.Players.LocalPlayer.CharacterAdded:Wait():WaitForChild("HumanoidRootPart");
local football = 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)
local target = workspace.Part
-- calculate the v0 needed to reach mouse.Hit.p
local v0 = (target.Position - x0 - 0.5*g*t*t)/t;
-- have the ball travel that path
local c = football:Clone();
c.Velocity = v0;
c.CFrame = CFrame.new(x0)
c.CanCollide = true;
c.Parent = game.Workspace;
end)
A visual of the problem: https://gyazo.com/89b011e1574ccbd641a7fbd0299cea4d

2 comments
I am a bit confused as to how I would subtract the positional value and isolate the base value
Instead of using Velocity, you'd need to switch to CFrame so you can get the next point. Then you can use something similar to: local Whole = CFrame.new(a, b); local Rotation = Whole - Rotation.Position; local Position = Whole.Position. A should be the part's original position and B should be the next step in the bezier iteration.