Im making a closet for my game which is supposed to be able to open. I have the closet itself, 2 doors and a hinge for each door. Doors are welded to hinges and hinges are welded to closet.
But when i try rotate the hinges the whole closet rotates which makes sense cause the hinges are welded. But how else do i do this? They need to be attached to the closet and anchored is not an option cause you can drag things around in my game so things cannot be anchored. Ive also tried playin around with hinge constraints but that didnt work (maybe i did it wrong idk)
There are many ways to do this. You could use HingeConstraints, which is the “proper” way to physically simulate doors that can swing open and react to motion. To set this up:
Insert an Attachment in the main Closet body part. Move it to where the door hinge connects.
Insert another attachment inside the door and move it to the exact same CFrame as the other attachment. Tip: you can match the CFrames exactly by copying the WorldCFrame from the first attachment into the second.
Insert a HingeConstraint into the door and match Part0 to the closet attachment and Part1 to the door attachment.
When you have the HingeConstraint selected, it will show you useful information about the orientation. Notice the orange disc, that’s the way the hinge rotates. For this door, you want it to face down/up. Think of the disc as a ‘wheel’ that rotates around its axis.
We need to change the way the hinge rotates. To do this, we need to change the orientation of our attachments. In this case, changing the Z to 90° should work.
To stop the door from rotating inwards, use LimitsEnabled in the HingeConstraint. The angle will also be previewed visibly on the hinge whilst selected.
When you do the same for the other door, I recommend you add a NoCollisionConstraint to one of the doors, then set Part0 to the left door and Part1 to the right door, so they don’t get stuck on each other and prevent fully closing.
To trigger the door to open, you can set the ActuatorType on the HingeConstraint to “Servo”. This turns the hinge into a mechanical joint that tends towards a target angle. To open/close the door, set the TargetAngle to a specific number (e.g. 0, or -90). Remember to set the MaxTorque (how strong the hinge motor is - should be a large number like 100-1000) and AngularSpeed (how fast the door opens).