.. _stdlib_spring_joint_component: =========== SpringJoint =========== This component creates a spring joint, also known as a distance joint. The joint will try to keep a fixed distance between two objects, ``node0`` and ``node1``, as defined by their positions at the moment the joint is created. The objects can rotate freely at the ends of the joint. Each of the two bodies will try to maintain the same position between its body and the position of the joint. This allows free rotation of the bodies. 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(10, 10, 0))) add_component(nodeA, new RigidBody()) add_component(nodeA, new SphereCollider()) // Create second body let nodeB = create_node(NodeData(position=float3(-10, 10, 0))) add_component(nodeB, new RigidBody()) add_component(nodeB, new SphereCollider()) // Create a joint that keeps two bodies at the distance they were created at — 20 add_component(create_node(NodeData()), new SpringJoint( node0 = nodeA, node1 = nodeB )) +++++++ Classes +++++++ .. _struct-spring_joint_component-SpringJoint: .. das:attribute:: SpringJoint : NativeComponent A spring joint. Keeps two bodies at a fixed distance, but allows rotations freely. :Properties: .. _function-spring_joint_component__dot__rq_node0_SpringJoint: .. das:operator:: SpringJoint.node0() : NodeId .. _function-spring_joint_component__dot__rq_node0_rq_clone_SpringJoint_NodeId: .. das:operator:: SpringJoint.node0 =(value: NodeId) A first body of the joint. It should have an active RigidBody component. :Arguments: * **value** : :ref:`NodeId ` .. _function-spring_joint_component__dot__rq_node1_SpringJoint: .. das:operator:: SpringJoint.node1() : NodeId .. _function-spring_joint_component__dot__rq_node1_rq_clone_SpringJoint_NodeId: .. das:operator:: SpringJoint.node1 =(value: NodeId) A second body of the joint. It should have an active RigidBody component. :Arguments: * **value** : :ref:`NodeId ` .. _function-spring_joint_component__dot__rq_allowCollision_SpringJoint: .. das:operator:: SpringJoint.allowCollision() : bool .. _function-spring_joint_component__dot__rq_allowCollision_rq_clone_SpringJoint_bool: .. das:operator:: SpringJoint.allowCollision =(value: bool) Used for disabling collision between the joined bodies. Default is false, disables collision. :Arguments: * **value** : bool .. _function-spring_joint_component__dot__rq_spring_SpringJoint: .. das:operator:: SpringJoint.spring() : float2 .. _function-spring_joint_component__dot__rq_spring_rq_clone_SpringJoint_float2: .. das:operator:: SpringJoint.spring =(value: float2) 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