CFrame Help (Rainbow Effect)

Hello! How can I create a cool effect like this:


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.

Use a beam, this isnt really anything to do with CFrame

Those are parts… I have gone under them and such. They are actual 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

Then apply the cubic bezier curve equation with p2 and p3

function cubicBezier(t, p1, p2, p3, p4)
	return (1 - t)^3*p1 + 3*(1 - t)^2*t*p2 + 3*(1 - t)*t^2*p3 + t^3*p4
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.

Hey, Im very confused, haha.

I would prefer CFrame

You could try tweeting it. Try looking at this TweenService | Documentation - Roblox Creator Hub

and check out some YouTube videos on tweening.

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

I wonder what he’s making this time :thinking:

2 Likes

Ask me 2 months ago. Perhaps you’ll find an answer

To DomTheMomRBLX (Two months ago),

I wonder what he’s making this time :thinking:

From,
ItsODRJR

3 Likes