.. _stdlib_hinge_joint_component: ========== HingeJoint ========== This component creates a hinge joint. Two objects, ``node0`` and ``node1``, will lose all but a single degree of freedom: they can now only rotate around the X-axis of the node that contains this component. The rotation can also be constrained by the ``angle`` parameter around the Y-axis. For example, ``angle = 15.`` would allow the bodies to rotate between ``-15`` and ``+15`` degrees, where the Y-axis of the joint represents ``0``. This joint can be used to make doors, fans, and even simulate a 2D ball-and-swing joint. The joint can be added as a component to either one of the two bodies, or to a new entity with a single joint component — the behavior of the joint is the same either way. Only one joint can be added to a single node. This component is provided by the ``engine.physics_core`` module, which is included in the ``engine.core`` module. Example:: require engine.core // Create first body let nodeA = create_node(NodeData(position = float3(0, 10, 10), scale = float3(1, 1, 10))) add_component(nodeA, new RigidBody()) add_component(nodeA, new BoxCollider()) // Create second body let nodeB = create_node(NodeData(position = float3(0, 10, -10), scale = float3(1, 1, 10))) add_component(nodeB, new RigidBody()) add_component(nodeB, new BoxCollider()) // Create joint that keeps two bodies at the distance they were created at - 20 add_component(create_node(NodeData(position = float3(0, 10, 0))), new HingeJoint( node0 = nodeA, node1 = nodeB, angle = 45. )) +++++++ Classes +++++++ .. _struct-hinge_joint_component-HingeJoint: .. das:attribute:: HingeJoint : NativeComponent A simple hinge joint. Rotate second body around first (or vise versa). :Properties: .. _function-hinge_joint_component__dot__rq_node0_HingeJoint: .. das:operator:: HingeJoint.node0() : NodeId .. _function-hinge_joint_component__dot__rq_node0_rq_clone_HingeJoint_NodeId: .. das:operator:: HingeJoint.node0 =(value: NodeId) A first body of the joint. It should have an active RigidBody component. :Arguments: * **value** : :ref:`NodeId ` .. _function-hinge_joint_component__dot__rq_node1_HingeJoint: .. das:operator:: HingeJoint.node1() : NodeId .. _function-hinge_joint_component__dot__rq_node1_rq_clone_HingeJoint_NodeId: .. das:operator:: HingeJoint.node1 =(value: NodeId) A second body of the joint. It should have an active RigidBody component. :Arguments: * **value** : :ref:`NodeId ` .. _function-hinge_joint_component__dot__rq_allowCollision_HingeJoint: .. das:operator:: HingeJoint.allowCollision() : bool .. _function-hinge_joint_component__dot__rq_allowCollision_rq_clone_HingeJoint_bool: .. das:operator:: HingeJoint.allowCollision =(value: bool) Used for disabling collision between the joined bodies. Default is false, disables collision. :Arguments: * **value** : bool .. _function-hinge_joint_component__dot__rq_angle_HingeJoint: .. das:operator:: HingeJoint.angle() : float .. _function-hinge_joint_component__dot__rq_angle_rq_clone_HingeJoint_float: .. das:operator:: HingeJoint.angle =(value: float) Allowed rotation around local Y axis of the node :Arguments: * **value** : float .. _function-hinge_joint_component__dot__rq_frictionTorque_HingeJoint: .. das:operator:: HingeJoint.frictionTorque() : float .. _function-hinge_joint_component__dot__rq_frictionTorque_rq_clone_HingeJoint_float: .. das:operator:: HingeJoint.frictionTorque =(value: float) Maximum amount of torque to apply as friction :Arguments: * **value** : float .. _function-hinge_joint_component__dot__rq_softLimit_HingeJoint: .. das:operator:: HingeJoint.softLimit() : float2 .. _function-hinge_joint_component__dot__rq_softLimit_rq_clone_HingeJoint_float2: .. das:operator:: HingeJoint.softLimit =(value: float2) Soft limit. When the angle goes out of bounds, the soft limits can pull it back with a spring force. The spring settings are packed to float2 where ``x`` is a spring frequency in Hz, and ``y`` is a spring damping (0 = no damping, 1 = critical damping, >1 = overdamp). If frequency = 0, the soft limit is disabled and the constraint will have hard limits. :Arguments: * **value** : float2