Hii! I need help calculating the projectile position like on this video? Thank you!

nicemike40
(nicemike40)
November 9, 2022, 3:23pm
#2
What specifically about this video are you trying to replicate? I don’t know what you mean by “calculating the projectile positions”

Im sorry for not being clear, I want to replicate the projectile movement like it goes up and down exactly on the video!

nicemike40
(nicemike40)
November 9, 2022, 4:48pm
#4
A lot of people like to define a Bézier curve for this sort of thing and then animate or tween the t value from 0-1

There are tons of forum posts about launching projectiles with Bézier curves, if you’re interested

For example

the most simple way possible
Quadratic beziers are the simplest case. Here’s a visual:
[image]
Endpoints P0 and P2. Control point P1.
Percentage t is between 0.0 and 1.0.
Get A = P0:Lerp(P1, t).
Get B = P1:Lerp(P2, t).
The green line in the gif is from A to B.
The point t-percent along the curve is then point = A:Lerp(B, t).
Edit: Cubic and higher-order beziers just have more layers of Lerping:
[image]
This ended being kinda fun.
A bezier curve might work for this: Bézier curve - Wikipedia
It’s this:
[image]
Where P0 is the starting point, P2 is the target, and P1 is just some value we choose that’s, say, ten studs above the midpoint between the start and end.
Stealing some equations from wikipedia for the equation of the tangent… and… done.
Put a Part in workspace and put this in a LocalScript in StarterPlayerScripts or something.
Test the game and click around.
local player = g…
2 Likes

Alongside what @nicemike40 has suggested for the up and down movement, there will also need to do some angle division to spread out the projectiles in a circle:

This code here can help you a lot:
local PartShooting = script.Parent -- part that fires rays
local Degrees = -45
for i = 360, -360, Degrees do
local Angle = i
local Rotation = CFrame.Angles(math.rad(Angle), 0,0)
local rayAngle = Ray.new(PartShooting.CFrame.Position, (PartShooting.CFrame * Rotation).lookVector * 20)
local anglePart, position = workspace:FindPartOnRayWithIgnoreList(rayAngle, {PartShooting})
-- Visualize the rays, not necessary, you can delete it
local VisualRay = Instanc…
1 Like

Arithysttt
(Arithyst)
November 10, 2022, 4:33am
#6
Thank you so much this helped!