I’m using a PrismaticConstraint for a moving part in an obstacle course but the prismatic constraint is moving on the x and z axis and I’m not sure why.
In the video I tested the prismatic constraint with test parts and the real obstacle course to show that it wasn’t working as intended.
Code for moving parts
Obstacles["Moving"] = function(comp)
local timer = comp:GetAttribute("Time")
local weight = comp:GetAttribute("Weight")
local move = comp.Move
local function physics(part)
if part:IsA("BasePart") then
part.Massless = true
part.CustomPhysicalProperties = PhysicalProperties.new(weight,0.3,0.4,1,1)
end
end
local function getPrimaryPart()
local prismOriginPart
if move:IsA("Model") then
for _,part in move:GetChildren() do
physics(part)
end
prismOriginPart = move.PrimaryPart
else move:IsA("BasePart")
prismOriginPart = move
physics(move)
end
return prismOriginPart
end
local prismOriginPart = getPrimaryPart()
local prism,a0,a1 = Constraints.Prismatic(prismOriginPart,comp.Goals["1"])
while true do
for i = 1,#comp.Goals:GetChildren() do
local targetGoal = comp.Goals:FindFirstChild(tostring(i))
a1.Parent = targetGoal
prism.TargetPosition = (targetGoal.Position - a1.WorldPosition).Magnitude
task.wait(timer)
end
end
end