What do you want to achieve? Keep it simple and clear!
I want to have a smooth curve similiar to this https://gyazo.com/1b4fb7eb8235872047080b6286dc0ac5
so basically I want my part to rotate smoothly and have the beam make a nice curve line.
What is the issue? Include screenshots / videos if possible!
Here is the issue, I made the bezier curve work but it doesn’t have a nice curve, even the curve size doesn’t go right.Here is a gif https://gyazo.com/fdba439b99feff1a93038e3f8cbae89e
I think the problem is because the part isn’t rotating, but i kept trying to make it rotate but it won’t work right.Also, it is a server script
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I have looked at youtube videos and many forums, and some free model bezier curves but I don’t understand why I have a problem here.I have tried to adjust the code many times but it won’t go smooth.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
local function QuadraticBezier(t,p0,p1,p2)
return (1-t)^2*p0+2*(1-t)*t*p1+t^2*p2;
end;
local Part0 = workspace.Part0;
local Part1 = workspace.Part1;
local Part2 = workspace.Part2;
local START = script.Parent;
local attach1 = workspace.Part0.Attachment
local attach2 = script.Parent.Attachment
for t = 0,1,0.01 do
wait()
local TargetPosition = QuadraticBezier(t , Part0.Position, Part1.Position, Part2.Position);
local ExitPosition = QuadraticBezier(t , Part2.Position, Part1.Position, Part0.Position);
START.Position = START.Position:Lerp(TargetPosition, t)
START.Orientation = ExitPosition
attach1.Orientation = TargetPosition
local beam = START.Beam
beam.CurveSize0 = (Part0.Position - Part1.Position).magnitude/2
beam.CurveSize1 = -(Part0.Position - Part1.Position).magnitude/2
end;
I’m not sure about the issue with the Beam object you’re currently using, but I’m certain that in the example you’ve provided in the first gif, Trailing is being used instead of Beaming.
If using the Beam object is not necessarily for you and you just want to achieve the same as in the example, you could easily manage to create it using an individual Trail object and 2 attachments attached to the moving part, also making the whole process much smoother and better-looking.
Thank you for your reply,and I understand you saying to use a trail instead which I already tried and it does look smooth https://gyazo.com/f44f3eda3100a434f8d671cfb8f5986f . but is there really no way to make the beam have the same effect?
Beams are not meant to be used this way…
You could possibly obtain the same effect with massive constant math calculations, which will also slow down your whole game. Trail would be capable of having the exact same effect with its many properties.
Roblox has an article on Bézier Curves | Roblox Creator Documentation. However, if you are wanting to create a beam and curve it then @EgoMoose has a community tutorial where he accomplished this to show the path a projectile would travel.
Edit:
Almost forgot to mention, while you seem to have the equation for a quadratic bezier curve you must derive it to be able to use it as a path.
Yea I already saw ego moose tutorial but it didn’t really help much with this, as his is moving the attachment with a mouse and not rotating.Whereas mine needs a to rotate to have that curve.
By rotate I mean the way it curves from sideways, so it has a beam curve with a peak point from going sideways then going down, but in egomoose his is only from a straight line and so he can just change the position of the attachment and change the curve size depending on the distance.
It doesn’t matter if it’s going sideways. Just because the curve curves in a different direction doesn’t mean you can’t make it curve sideways. I actually created a bezier curve lab awhile ago when I was first learning about them, so maybe it might help you. I just published it so you can use it.