Adding the Constraint
Remember, constraints are a way of connecting two attachments to move in a specific way. This door will use a HingeConstraint, a common constraint that rotates objects along the axes of two attachments.
Under DoorFrame, create a new HingeConstraint.
In the constraint’s properties, find Attachment0. Click the empty box right of the property and then, in the Explorer, click DoorAttachment.
Repeat the same process by connecting Attachment1 to FrameAttachment. The properties should appear as below.
Test the project by walking into the door with your character.
Issue: Parts not moving
Issue: Door not swinging as expected
- Check anchoring. For instance, the door should not be anchored.
- Make sure that the door’s motion isn’t blocked by terrain or nearby parts.
- Ensure the axis of each attachment is pointed up (see Rotating Attachments).
Adjust the Door
The door is currently able to swing past the door frame. This can be fixed by adjusting the hinge limits.
In the properties for HingeConstraint, find and toggle LimitsEnabled. When active, you can set the rotation limits of the hinge.
To make sure this is oriented correctly, select DoorAttachment and use the rotate tool so the orange arrow points towards the door frame, like below.
Axis Arrow Colors
Remember that the yellow axis arrows affect the pivot of the hinge. Limits are affected by the orange axis arrows.
Under the Limits section of the properties, both LowerAngle and UpperAngle to -90 and 90, respectively. This creates a range of motion like the image on the left.
Test the door and notice that the hinge is now limited.
Issue: Door limits don’t work as expected.
It’s possible that the orange axis on an attachment isn’t correctly aligned. Select DoorAttachment, and make sure that a green plane with an arc points towards the door frame, the image below.
With the door complete, take some time to explore using hinge constraints in different situations, such as a trap door or a swinging axe trap.
Previous Page Getting Started