Modeling trajectory of object with beams

Hey everyone,
I’m trying to model the trajectory of a ball (sphere) with beams. The issue however, is that I am unable to figure out the formula to get the correct curve for the sphere as I am not tweening the ball, instead I am just updating it in a loop (several reasons) Below is a video of the ball and the curve.

My base code for the trajectory of the ball was from this post:
Calculation of trajectories in Roblox Studio - Resources / Community Tutorials - DevForum | Roblox
ball code:

function BallHandler:BeginTrajectory(part, cameraCF)
	local function Position(Origin, Initial, g, Time)
		return Origin + Initial * Time + g * Time * Time / 2
	end

	local OriginPart = part
	local Gravity = Vector3.new(0, -workspace.Gravity, 0)
	local Velocity = 0.7
	local GoTo = (OriginPart.CFrame.LookVector * 100*(Velocity*2) ) + (OriginPart.CFrame.UpVector * 51*Velocity)
	local StartPosition = OriginPart.CFrame.Position
	local Total = 0


	self.Ball.Parent = workspace
	game:GetService("Debris"):AddItem(self.Ball, 5)
	game:GetService("Debris"):AddItem(self.Ball.PrimaryPart, 5)
	local CurveSize0 = workspace.Start.Beam
	local Attachment0 = workspace.Start.Attachment1
	local Attachment1 = workspace.Start.Attachment2
	--Attachment0.WorldPosition = part.Position
	
	coroutine.wrap(function()
		while self.Ball and self.Ball.PrimaryPart do
			if not self.Ball.PrimaryPart then return end
			local dt = game:GetService("RunService").Heartbeat:Wait()
			if self.Ball.PrimaryPart then
				Total += dt*(Velocity*1.65)
				
				local g = workspace.Gravity
			
				--Attachment1.WorldPosition = Position(StartPosition, GoTo, Gravity, Total) + Vector3.new(0,-g*dt^2/2,0)
				--CurveSize0 = 9.81 * .2 * 0.7
				self.Ball.PrimaryPart.CFrame = CFrame.new(Position(StartPosition, GoTo, Gravity, Total))		
			end

		end
	end)()
end

As you can see in the script, I have tried various approaches to mirroring the trajectory with the curve, however none of them work. If anyone has any solutions or ideas, I’d be willing to try them.

Thanks in advance!

Hello there! I have no clue how to fix this as I myself was researching how to figure out something similar; I was just reading a similar post about this the other day, trying to find out a solution. I’m not sure whether this topic would be of any use, but it’s worth a look!

Hey there, sorry for the late reply, that was the equation that I was using actually. Didn’t end up working for us though

1 Like

There is also this Ego Mooses tutorial check it out and see if it works for you as it has for me.

will try that out as that might be the correct equation that I was looking for, thanks

This actually worked, thanks so much!