Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Issue With Rotations... Any Help?

THIS THREAD USES PICTURES TO WALK THROUGH THE PROBLEM So I am making a bezier curve based roller coaster maker... Picture 1: Click Here As you can probably see, there are a few problem spots... Problem 1: Click Here Problem 2: Click Here However, some spots work just fine... Picture 2: Click Here

I believe this has something to do with some points having a negative Z rotation while the other rotation point has a positive Z rotation, and it causes this code...

for i=1,d do --i/d is what helps tell the brick where to position itself, as there is 20 points in each section
--Code not important to rotation
local CP=script.Parent.ControlPoints
t.Rotation=CP.p1.Rotation:Lerp(CP.p3.Rotation,i/d)
end

... to rotate in bad ways. Any help would be greatly appreciated. Thank you.

1 answer

✓ Accepted answer

When it comes to rotations, it's much simpler to manipulate CFrame instead.

Also, regular lerp doesn't work too nice for rotation, you need to make a slerp function for that. Luckily for you, there is lerp method for CFrame as well, which will handle rotation slerping for you.

Here is my take on the problem, but I can't really test it:

for i=1, d do
	--Code not important to rotation
	local CP = script.Parent.ControlPoints

	-- I will split the CFrame in components, because I don't know the point position
	local cf = { CP.p1.CFrame:lerp( CP.p3.CFrame, i/d ):components() }
	local pos = t.Position

	t.CFrame = CFrame.new( pos.x, pos.y, pos.z, cf[4], cf[5], cf[6], cf[7], cf[8], cf[9], cf[10], cf[11], cf[12] )
end

Please give feedback whether it does what you want or not, since I don't have roblox studio available at the moment.

1 comment

1

Thank you SO much, this means a lot to me. The rotation was the only thing holding me back from touching the tool for a long time. Now I am much closer to putting my plans into action.

This discussion is preserved as it was. New answers, comments, and votes are closed.