Hey Developers! I decided to mess around with this New Beta in my projects Called Drag Detectors Considering that it would be useful for the project I am making.
Now I am making a sliding double door. In other words, when you move the door, I want the second door to slide, but on the opposite side to cause natural Movement
In other words. This is what I have right now:
You can see that there is one door (right door) moving to the right in a open position, before, moving to left to be closed.
How can I make it, so the other door (left door) is moving in left direction, while the right door is moving right? And same with closing a door, when the player drags it to close the door, how can I make so the left door is moving right, and right door is moving left when closing a door…
Does it make sense? How can I do something like this? Any ideas?
for your ease, handle this all in a script. make sure you have an attachment or invisible part or vector3 variable that’ll represent the center of both doors, as a starting position. reffering to it as startingPos
have both of your drag detectors instantiated and have a function dedicated to when either of them are activated, so there are 2 functions. comment label them right and left since the internals of both are similar.
for one of the functions (we’ll exemplify with the right door function) you are going to refer to the LEFT door and tweenObj:Play() the Vector3 of the RIGHT doors Vector3 subtracted by the startingPos. If it doesnt work properly or it just goes the same way as the right door then I have it backwards. Do the same for the other function (so the left door) and youd refer to the RIGHT doors’ Vector3.
the reason why having 2 functions is a better play is because having a runservice.RenderStepped function running the Vector3 of the doors is a little overkill and can be a logic nightmare sometimes, also considering that were using drag detectors so having values being changed per frame can be hard to deal with.
Hey, Thanks you for you reply. A couple of Questions, as I am New(ish) to Drag Detectors and there isn’t much resources on them besides the Docs.
I know you mentioned the TweenService. The issue is that these doors are models and not a BasePart, meaning that I will have to Use PivotTo() and GetPivot(). Meaning if I were going down that route how would I go about the smoothness of “The slide animation”.
Do I really Need to Tween it with the DragContinue Event? If so Do I have to worry about limits (How many times it fires) / How can I get the time to Tween it to the position (If I tweened it). My goal is to have it nice and smooth in other words, Not when the Dragging ends it updates, rather it updates while the user is Dragging it (All Drag dectectors are disabled when one is being moved).
local function SlideDoors(DoorNeededToSlide, DraggedDoor, MiddlePoint)
DoorNeededToSlide:PivotTo(CFrame.new(DraggedDoor:GetPivot().Position - MiddlePoint.Position )) --Issue is here with Position
end
game.Workspace.RepellingDoors.LeftDoor2.DragDetector.DragContinue:Connect(function()
SlideDoors(game.Workspace.RepellingDoors.LeftDoor1, game.Workspace.RepellingDoors.LeftDoor2, game.Workspace.TestMiddlePoint)
end)
Its a starting point, and I mean It is Sliding, but it does it goes to the origin of the game… Stilling trying stuff out.
This is gonna sound stupid since I’ve literally never touched a dragdetector in my life, but from what you’re telling me it uses cframes and stuff like that, so if the right door works fine you can probably make the position the right door moves to a variable, then use it negative
so basically negate the position of the working door as a baseline
All you Need to know basically about DragDetectors is that DragContinue Fires when the Drag detector is fired and moving (changing it’s position). My Drag detector is stuck within an Axis to move from.
How would I " negate the position of the working door as a baseline ". I know a little about how CFrames works, I have worked with them a Tad, but I’ll confused on how I would get it haha.
If it Helps, the variables in My function Are:
DoorNeededToSlide - This is the door that doesn’t move with the Drag dectector
DraggedDoor - This is the dragged door from the Drag dectector
MiddlePoint - This is this part, in the middle of the 2 Doors
Any ideas on how I could do what your talking about?
just use -cframe, its pretty much the same thing as inversing a cframe (from my knowledge)
local cframe = CFrame.new(50, 0, 17)
print(-cframe) -- should return -50, 0, -17
cframe = CFrame.new(-50, 0, 17)
print(-cframe) -- should return 50, 0, -17
(replace -cframe with cframe:Inverse())
this is what should happen from my knowledge. putting - INSIDE the cframe statement of course changes a single axis, the - of a cframe should be its inverse
so just use the negative cframe/position of the way you’re moving your door
nuh uh not like that, bring your working code back, then cut everything that was inside the PivotTo and make that a cframe, then do the inverse logic you need
No, you pivot the working door to the same cframe as when it was working. You pivot the opposite door to the inverse of that cframe. I’ll try to make a test demo in studio.
EDIT: YOU MAY HAVE TO USE CURSORRAY TO POSITION THE DOORS