Notice how the Parts spawn, and then they go in a rainbow motion through the air until it reaches a specific location? (I know how to make them spawn in a random area, but for the purpose of this lets just say that it spawns in a specific area, and THEN does the rest.)
One more thing… Those are PARTS. It isnt a beam, but individual parts.
You can use bezier curves to draw something like this, however in your case the midpoint at the top of the arc should go “up” relative to the world and not “right” relative to the CFrame.lookAt from current position to target position.
Details on the method
So here is how it goes I believe:
--percent1,percent2 = 0.25, 0.25
--1/4 of the length of the positionToLookAt vector
local function bezierCurvePoints(position,lookAt,upLength,percent1,percent2)
local upVector = Vector3.new(0,1,0)
local positionToLookAt = lookAt-position--vector from position to lookAt/Target point
local unitDirection = positionToLookAt.Unit
--find the right vector relative to the world
local rightVector = positionToLookAt:Cross(upVector).Unit
--find the new upvector
local upVector = rightVector:Cross(unitDirection).Unit
local midpoint = position+positionToLookAt/2
--right length influences the length it goes "right"
local midpointToTheSky= midpoint + upVector *upLength
local p2 = midpointToTheSky- positionToLookAt*percent1
local p3 = midpointToTheSky+ positionToLookAt*percent2
return p2,p3
end
Another option is to use the quadratic projectile motion equation to model the arc, it should also be more physics like if you are going for a more realistic approach.
Use my (ok i guess you cant credit math but I kinda discovered it for myself when messing around with the vertex formula) formula for getting arc motion within specific parameters
Then have h be a random value with t being the distance between the start and the end. Alternatively you could also just use my Math++ library