How would i go about creating a parabolic motion

  1. What do you want to achieve? Parabolic projectile motion with an option to make it more 3D

  2. What is the issue? I have no idea how I would go about this

  3. What solutions have you tried so far? I couldn’t find anything that could help me

What I want is for the projectile to follow a parabolic pattern much like this:


The projectile would go towards the direction based on the mouse position.

I appreciate any help you can provide.

local x = 0

while true do
	x += 1
	print(math.floor(10 - 20 * math.cos(x)))
	wait()
end

Take a look at the output, this is a general idea of what you may want.

This is actually called a Bèzier curve. Roblox has a tutorial on it.

The issue with bezier curves is that they need points and say you point at a player and that player moves out the way once you fired the projectile and it will end up stuck at target’s previous position

Yeah, it does but how would I make a projectile follow such pattern?

The tracer should be bound to the time that it was fired so that it appears accurately positioned on each client. So for this scenario, you may want to use RunService.Stepped, it passes a time & deltaTime value.

This is actually not called a bezier curve, it is known as a simple alternating curve. To apply it to 3d you’ll for a given time step, t, notice that if you just wanted it to go striaght you could just do player.Position + target.Position*t. We’ll call this reference value straight. If we just wanted it to go right towards the target we could just do something like

local vectorBasis = Instance.new("Vector3Value")
vectorBasis.Value = player.Position
local tweenService = game:GetService("TweenService")
local tween = tweenService:Create(vectorBasis, TweenInfo.new(1), {Value = target.Position})
tween:Play()

vectorBasis.Changed:Connect(function()
  projectile.Position = vectorBasis.Value
end)

What we need to do now is modify that second to last line. We’ll first create a coordinate space so we can define “flat”. We need to create a constant reference point to avoid distortion. We can do this by using the built-in lookAt matrix constructor.

local coordinateSpace = CFrame.lookAt(player.Position, target.Position, Vector3.new(0,1,0))

We can then multiply the rightVector by a oscillating value and apply that as an offset

local vectorBasis = Instance.new("Vector3Value")
vectorBasis.Value = player.Position
local tweenService = game:GetService("TweenService")
local tween = tweenService:Create(vectorBasis, TweenInfo.new(1), {Value = target.Position})
tween:Play()
local coordinateSpace = CFrame.lookAt(player.Position, target.Position, Vector3.new(0,1,0))
vectorBasis.Changed:Connect(function()
local t = inverseLerp(player.Position, target.Position, vectorBasis.Value)
  projectile.Position = vectorBasis.Value + coordinateSpace.RightVector * (15*math.cos(t)
end)

Im not sure what do you mean by tracer is it the x? and how would I translate it to a vector so the projectile knows where it has to go?

Hi! I believe you forgot to define inverseLerp