How do I make a projectile arc towards player?

Here is a video with timestamp of the effect I’m trying to create: Let's Play Aquaria [16] - Mermog Cave - YouTube

As you can see the arc of the bullet toward the player. I was able to do this but then they just stop. Since I’m using a bezier curve It stops when it reaches the player because I need three fixed points. is there a way I can make it intercept where the player is and then curve back at them in the player had moved??? (The farther away the player is the more strait the arc is)

Test - Roblox here is a model of what I have sofar and the code is below


–Made by Its4Realzies

–[[

There are three fixxed positions P0, P1, P2

P0 is the Boss
P1 is the control point
P2 is the Players torso positon

It will start at P0 and then move in an arc towards P2

]]–

local sP = script.Parent

local part = Instance.new(“Part”,workspace)
local position0 = sP.Boss
local position1 = sP.ControlPart
local position2 = sP.PlayerTorso1
local position3 = sP.PlayerTorso2

local p1 = position1.CFrame

part.Anchored=true

local t=0
local t2=0
local onlyOnce = true

local startPositionDad = position0
local targetPositionDad = position2

local function bezierPathDad()
–print(“Comingg from:” … startPosition.Name)
–print(“Heading to:” … targetPosition.Name)
–print(t2)

if t2 <= 1 then
	--local pFinalX = math.pow(1-t,2)*startPosition.X+(1-t)*2*t*p1.X+t*t*targetPosition.X;
	--local pFinalZ = math.pow(1-t,2)*startPosition.Z+(1-t)*2*t*p1.Z+t*t*targetPosition.Z;

	local pFinalX = math.pow(1 - t2, 2) * startPositionDad.CFrame.X + (1 - t2) * 2 * t2 * p1.X + t2*t2 * targetPositionDad.CFrame.X;
	local pFinalZ = math.pow(1 - t2, 2) * startPositionDad.CFrame.Z + (1 - t2) * 2 * t2 * p1.Z + t2*t2 * targetPositionDad.CFrame.Z;
	t2 = t2 + 0.01
	part.CFrame=CFrame.new(pFinalX,13,pFinalZ)
else 
	
	startPositionDad=targetPositionDad		
	targetPositionDad=position3

	--postition3 = wherever the person is
	 		
	t2=0
end

end

local function bezierPath2(startPosition, targetPosition)
print(“Comingg from:” … startPosition.Name)
print(“Heading to:” … targetPosition.Name)
print(t)

if t<=1 then
	--local pFinalX = math.pow(1-t,2)*startPosition.X+(1-t)*2*t*p1.X+t*t*targetPosition.X;
	--local pFinalZ = math.pow(1-t,2)*startPosition.Z+(1-t)*2*t*p1.Z+t*t*targetPosition.Z;

	local pFinalX = math.pow(1 - t, 2) * startPosition.CFrame.X + (1 - t) * 2 * t * p1.X + t*t * targetPosition.CFrame.X;
	local pFinalZ = math.pow(1 - t, 2) * startPosition.CFrame.Z + (1 - t) * 2 * t * p1.Z + t*t * targetPosition.CFrame.Z;
	t = t + 0.01
	part.CFrame=CFrame.new(pFinalX,13,pFinalZ)

end

end

local function bezierPath(startPosition, targetPosition)
–print(“Comingg from:” … startPosition.Name)
–print(“Heading to:” … targetPosition.Name)
–print(t2)

if t2 <= 1 then
	--local pFinalX = math.pow(1-t,2)*startPosition.X+(1-t)*2*t*p1.X+t*t*targetPosition.X;
	--local pFinalZ = math.pow(1-t,2)*startPosition.Z+(1-t)*2*t*p1.Z+t*t*targetPosition.Z;

	local pFinalX = math.pow(1 - t2, 2) * startPosition.CFrame.X + (1 - t2) * 2 * t2 * p1.X + t2*t2 * targetPosition.CFrame.X;
	local pFinalZ = math.pow(1 - t2, 2) * startPosition.CFrame.Z + (1 - t2) * 2 * t2 * p1.Z + t2*t2 * targetPosition.CFrame.Z;
	t2 = t2 + 0.01
	part.CFrame=CFrame.new(pFinalX,13,pFinalZ)
elseif onlyOnce == true then
	onlyOnce = false
	game:service'RunService'.Stepped:connect(function() bezierPath2(position2, position3) end)
end

end


I’m not too interested in reading any of your code right now, so I’ll link a good resource.

Try this out. Modeling a projectile's motion

1 Like

Read this three times already. I’m trying to make a bezier curve projectile and for the player to be an intercept or something else to achieve the effect in the video above.