So I’ve set my double door up, but need to make sure the right handle’s tween is inverted, as otherwise it goes the wrong direction.
I attempted to do this with a ToObjectSpace statement
if currentKnob.CFrame:ToObjectSpace(doorModelBoundingBox).Position.X > 0 then
However, since the right door is actually a invert of the left door, that means it’s relative space also changed, making this check not function as intended, causing it to fire onto all handles
im not 100% sure if this is what you where trying to achieve and i cant guarantee this is the best way but this is what i came up with:
local CheckSide = function(From:BasePart,To:BasePart,Dir:string)
return CFrame.new(From.Position,To.Position).LookVector.Unit[Dir] > 0
end
Side = CheckSide(workspace.Door1,workspace.Door1.Knob,"X")
the Dir(Direction) is relative to the from part true being left, false being right and should work no matter the orientation of the door itself because its a look vector sorry if its not exactly what you wanted.
local CheckSide = function(From:CFrame, To:MeshPart, Dir:string)
return CFrame.new(From.Position,To.Position).LookVector.Unit[Dir] > 0
end
local Side = CheckSide(doorModelBoundingBox,currentKnob,"X")
if Side == true then
print("true " .. currentKnob.Name)
knobRotationRad = knobRotationRad * -1
knobPartialRotationRad = knobPartialRotationRad * -1
end
Which I found a few oddities with
The right knob actually returns true with this setup instead of false
This works completely fine normally but breaks if I rotate the entire door by 90 degrees across the y axis, if I do that I have to set the Dir to Z instead
local CheckSide = function(From:CFrame, To:MeshPart)
if math.abs(CFrame.new(From.Position,To.Position).LookVector.X) > 0.55 then
return CFrame.new(From.Position,To.Position).LookVector.Unit["X"] < 0
else
return CFrame.new(From.Position,To.Position).LookVector.Unit["Z"] > 0
end
end
local Side = CheckSide(doorModelBoundingBox,currentKnob)
if Side == false then
knobRotationRad = knobRotationRad * -1
knobPartialRotationRad = knobPartialRotationRad * -1
end
And it worked
Weirdly after
this
if math.abs(CFrame.new(From.Position,To.Position).LookVector.X) > 0.5 then
return CFrame.new(From.Position,To.Position).LookVector.Unit["X"] < 0
else
return CFrame.new(From.Position,To.Position).LookVector.Unit["Z"] > 0
end
stopped working for no explainable reason.
So I’m thinking my current workaround is kinda shakey and might not scale well