Revision Difference
PhysicsJoints#563588
<cat>Code.Physics</cat>
<title>Joints</title>
⤶
<note>⤶
This page is a work-in-progress. It requires more sections, fact checking and screenshots.
⤶
<note> ⤶
This page is a work-in-progress. More sections and fact-checking are needed.
</note>
⤶
# Overview⤶
A PhysicsJoint constrains the motion of one PhysicsBody with respect to another. When a PhysicsBody is dynamic, joints attached to the body may influence its movement.
⤶
Take for example two cubes connected by a SpringJoint. Each cube has a BoxCollider Component that defines its shape in the PhysicsWorld, as well as a Rigidbody Component that provides a dynamic PhysicsBody for the Collider to attach to.
⤶
<note>⤶
TODO: Add a screenshot of the components.
</note>⤶
⤶
Pulling the first cube causes the second to trail behind, and vice versa.
⤶
<note>⤶
TODO: Add a diagram of a cube being pulled.⤶
</note>⤶
⤶
When a body is static or keyframed, joints will have no effect on the motion of that body, but a dynamic body attached to the other end of the same joint may be affected.
⤶
<note>⤶
TODO: Add a diagram of a dynamic cube dangling from a static collider.⤶
</note>⤶
⤶
# Joint Components⤶
⤶
In the scene editor, PhysicsJoints may be created by adding to a GameObject one of several different Joint Components, each of which will be described below in further detail.
⤶
<note>⤶
TODO: Fill out sections for each type of PhysicsJoint.
</note>⤶
⤶
## Fixed Joint⤶
⤶
## Spring Joint⤶
⤶
## Slider Joint⤶
⤶
## Hinge Joint⤶
⤶
## Ball Joint⤶
⤶
#Overview⤶
A PhysicsJoint constrains the motion of one PhysicsBody relative to another. If a PhysicsBody is dynamic, any joints attached to it may influence its movement.
⤶
For example, consider two cubes connected by a SpringJoint. Each cube has a BoxCollider component that defines its shape in the PhysicsWorld, along with a Rigidbody component that provides a dynamic PhysicsBody for the collider to attach to.
<upload src="b5b0a/8dd52968aed2311.png" size="374443" name="sbox-dev_iwL4qnCs3S.png" />⤶
⤶
When the first cube is pulled, the second follows behind due to the spring force.
<upload src="b5b0a/8dd5296a7683d96.mp4" size="2463129" name="sbox-dev_K4rfX0LwHg.mp4" />⤶
⤶
If a body is static or keyframed, joints will not influence its movement. However, any dynamic body connected to the same joint may still be affected.
<upload src="b5b0a/8dd5296d6b84b7f.mp4" size="1999227" name="sbox-dev_SqT0w7uEAL.mp4" />⤶
⤶
#Joint Components⤶
⤶
In the Scene Editor, PhysicsJoints can be created by adding a Joint Component to a GameObject. Each type of joint provides different movement constraints, which are described below.⤶
⤶
<note>
A **joint component** does not need to be on the same **GameObject** as the **Rigidbody**. This allows for offsets, such as hinges positioned away from the connected bodies. ⤶
⤶
<upload src="b5b0a/8dd52996a0e2cb1.png" size="1018" name="sbox-dev_FWWnEuAMNx.png" />⤶
⤶
</note>⤶
##Fixed Joint⤶
⤶
A FixedJoint welds two physics objects together, keeping them at a fixed distance while also maintaining their relative rotation. The joint attempts to preserve the transforms from the moment the connection is established.
⤶
<upload src="b5b0a/8dd52973efa6a25.mp4" size="2463871" name="sbox-dev_WYoWbVnx19.mp4" />⤶
⤶
Frequency and Angular Frequency control the stiffness of the joint.
⤶
##Spring Joint⤶
⤶
A SpringJoint tries to maintain a set distance between two objects. The initial distance is based on their separation when the connection is established.⤶
⤶
<upload src="b5b0a/8dd5297edcba8f5.mp4" size="2460659" name="sbox-dev_4Gzv6raAGO.mp4" />⤶
⤶
Frequency controls the stiffness of the spring.⤶
⤶
Min Length defines how close the objects can get before being pushed apart.⤶
⤶
Max Length defines how far they can separate before being pulled back together.⤶
⤶
##Slider Joint⤶
⤶
A SliderJoint constrains movement to the Z-axis relative to the connected body, similar to a drawer opening and closing.⤶
⤶
<upload src="b5b0a/8dd52989003768c.mp4" size="3619407" name="sbox-dev_83qLsVfXrv.mp4" />⤶
⤶
Min Length and Max Length define the range of movement along the axis.⤶
⤶
##Hinge Joint⤶
⤶
A HingeJoint allows two physics objects to rotate around a single axis, like a door hinge.⤶
⤶
<upload src="b5b0a/8dd5299789c51ad.mp4" size="2028143" name="sbox-dev_yZFCGqDsyn.mp4" />⤶
⤶
##Ball Joint⤶
⤶
A BallJoint fixes two objects together while allowing rotation in any direction, similar to a shoulder joint. It supports optional twist and angular limits.⤶
⤶
<upload src="b5b0a/8dd5299e2768506.mp4" size="2251277" name="sbox-dev_w9jXj8YEGk.mp4" />