Rotating Motor6D on a pivot

Hello, I want to tween (rotate) a motor6d on a pivot as the title suggests.

I am making an unanchored door which the player will be able to weld onto moving vehicles and other unanchored parts so I can’t tween the door hinge itself, and have to use a motor6d to do so.

I have tried some solutions such as fiddling with the cframe, tweening C1 and C0, I have a basic understanding of CFrame but I just don’t know how to get this to work.

doorHandle.ClickDetector.MouseClick:Connect(function()
	-- if debounce is false, do the things below, if it is true, wait until it becomes false
	if doorDebounce == false then
		
		-- if the door is open, set doorOpen to true, if its closed, set doorOpen to false
		if doorOpen == false then
			
			doorOpen = true
			doorDebounce = true

			tweenService:Create(motor6d,tweenInfo,{C0 = motor6d.C0 * CFrame.Angles(0,math.rad(90),0)}):Play()
			mainDoorPart.door_open:Play()
			
			task.wait(delay)
			
			doorDebounce = false
		else
			
			doorOpen = false
			doorDebounce = true

			tweenService:Create(motor6d,tweenInfo,{C0 = motor6d.C0 * CFrame.Angles(0,math.rad(-90),0)}):Play()
			mainDoorPart.door_close:Play()
			
			task.wait(delay)

			doorDebounce = false
		end
	end
end)

Here is what ends up happening after I run the script

It just rotates really weirdly, and I think that is because I have an offset cframe on the motor6d.
image
Here are the properties of the Motor6D, I have also read about rotating offset parts on a pivot but none of the results talk about Motor6D or a method that could work with Motor6D and unanchored parts.

Any help is appreciated.

2 Likes

You can make a HingeContraint (with the door’s attachment set to the same place where a door normally would have hinges), and then set its ActuatorType to Servo. After that, you can just simply edit the TargetAngle of the hinge. Just make sure that AngularSpeed is not set to 0.

1 Like

What I really did for my door is make part A and B for the door to open and close to.

When toggled, it’s CFrame gets tweened to either A or B, depending it’s current status.

You don’t need to have so many complicated Motor6Ds or any attachments.


If you do end up doing this, position your A and B parts, then set the size to 0.001,0.001,0.001 so it doesn’t interfere with the actual door.

1 Like

As @fofogoofan12 said just use a HingeConstraint. I’ve used them set to Servo for my vehicle doors for years.
The other way is to use a Motor and not a Motor6D. Then you can just set the DesiredAngle (like setting the TargetAngle of a HingeConstraint) to whatever angle you want.

1 Like

Sorry but I need the door to be unanchored so the player will be able to weld it to their moving vehicles, and you cant tween unanchored parts, this is why I used motor6ds, because you can tween the C0 and C1 values even when the model is unanchored.

Sure, its kinda late for me right now so I will try that tomorrow

Also make sure your HingeConstraint Servo max force is not set to something huge so if the door gets caught on a lamppost or a player it won’t get the vehicle stuck.
You can also play with the Restitution, which will give a bit of a more natural movement instead of a linear closed to open movement.
Check out how it looks at my Suspension Test place on my profile.

1 Like

Sure thing! Ill make sure to do that, the hinge being able to get stuck shouldnt be that big of a problem I think.

So if you set the C0 Z value to half the door’s horizontal length then you should be theoretically setting the pivot to the border of the door.

Also you should then modify the C1 so that it’s in its original position.

I believe your current problem is that the pivot reaches beyond the door’s bounds which causes this weird effect.

Part0 of the motor6d should be the door.

Part1 of the motor6d should be the frame.

1 Like

Yep its probably due to this reason. If you want to visualize a Motor6D and edit this pivot position I recommend using a plugin like RigEdit or the roblox Constraints visualization which I believe displays Motor6ds as well.

1 Like

If you’re trying to make a physics door with hinges and such, you could try to look for the first option in the toolbox. You can try to learn from it.

Wow this worked perfectly, I used rigedit and it immediately worked, thanks so much!

Edit: @dthecoolest but now I just realized that I can somehow phase through the door now, even when its cancollide is set to true, do you know how to fix this?

Edit 2: it seems like changing a property of the door parts after it has completed its move with the motor6d fixes it, here is a local function I used to do this

-- fixes collision after motor6d tween
local function fixCollision()
	
	for _,v in pairs(door:GetChildren()) do
		
		if v:IsA('BasePart') then
			
			v.Massless = true
			task.wait()
			v.Massless = false
		end
	end
end
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.