Hello all,
I am trying to create a road plugin which is able to create and position road segments. One of the key features of the plugin is it is able to create sloped curves without the prominent tilt that you would get from plugins such as Archimedes 2.
I have managed to create the functions for creating curves and placing straight segments, but when the plugin creates slopes on multiple axes (so if I slope the road segment and also curve it), it still creates the tilting effect, and the orientation of the segment of the X Axis is a decimal number, which it shouldn’t be.
Here is the angle I expected:
Here is the actual outcome:
This can be problematic because if the orientation of one segment is a little bit off, it can create some weird angles in future segments:
I need to be able to round the X value on the segment to 0 in order to ensure that the road segment is level. I have searched the Developer Forum to find articles which could help me accomplish this, but I couldn’t find anything
Here is the code for the sloping tool:
local function slopeSegment(direction)
if direction == "Up" then
local currentPivot = newRoadSegment:GetPivot()
if currentPivot ~= nil and newRoadSegment.PrimaryPart then
local targetAngle = CFrame.Angles(0, 0, -math.rad(slopeIncrement))
local pivot = currentPivot * targetAngle
newRoadSegment:PivotTo(pivot)
print(newRoadSegment:GetPivot())
end
elseif direction == "Down" then
local currentPivot = newRoadSegment:GetPivot()
if currentPivot ~= nil and newRoadSegment.PrimaryPart then
local targetAngle = CFrame.Angles(0, 0, math.rad(slopeIncrement))
local pivot = currentPivot * targetAngle
newRoadSegment:PivotTo(pivot)
print(newRoadSegment:GetPivot())
end
end
GUI.Controls.Info.Slope:FindFirstChild("Number").Text = newRoadSegment.Road.Orientation.Z
end
Any help on this would be much appreciated.