Photon Quantum 2.1.1

Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
Quantum.Physics2D.SpringJoint Struct Reference

A Joint that attaches a Physics Body to an anchor as if connected by a spring, trying to keep them a certain distance apart. The connected anchor can be a world-space position or another entity with at least a transform component. More...

Public Member Functions

 SpringJoint (FP spring, FP damper, FP distance, EntityRef connectedEntity, FPVector2 anchor, FPVector2 connectedAnchor)
 Constructs a SpringJoint struct. Use CreateJoint overloads instead to create a Joint of type JointType.SpringJoint. More...
 
void GetStiffness (PhysicsBody2D *jointBody, PhysicsBody2D *connectedBody, out FP frequency, out FP dampingRatio)
 Computes the frequency and dampingRatio based on the joint Spring and Damper capacities, given the physics body(ies) involved. More...
 
void SetStiffness (FP frequency, FP dampingRatio, PhysicsBody2D *jointBody, PhysicsBody2D *connectedBody=null)
 Computes and sets the Spring and Damper capacities based on the target frequency and dampingRatio , given the physics body(ies) involved. More...
 

Static Public Member Functions

static void ComputeStiffness (FP frequency, FP dampingRatio, PhysicsBody2D *jointBody, PhysicsBody2D *connectedBody, out FP spring, out FP damper)
 Computes the spring and damper capacities based on the target frequency and dampingRatio , given the physics body(ies) involved. More...
 
static Joint CreateJoint (FP frequency, FP dampingRatio, FP distance, PhysicsBody2D *jointBody, EntityRef connectedEntity=default, PhysicsBody2D *connectedBody=null, FPVector2 anchor=default, FPVector2 connectedAnchor=default)
 Creates a 2D Physics2D.Joint of type JointType.SpringJoint. More...
 
static Joint CreateJoint (FP spring, FP damper, FP distance, EntityRef connectedEntity=default, FPVector2 anchor=default, FPVector2 connectedAnchor=default)
 Creates a Joint of type JointType.SpringJoint. More...
 

Public Attributes

FPVector2 Anchor
 The anchor offset, in the local space of the joint entity transform. This is the point considered for the joint constraints and where the joint forces are applied. More...
 
FPVector2 ConnectedAnchor
 If the joint has a ConnectedEntity, this represents the anchor offset relative to it, in local space. Else, this is the position in world space considered as target anchor. More...
 
EntityRef ConnectedEntity
 A target entity that this joint might be connected to. If set to EntityRef.None, the ConnectedAnchor represents the target anchor position in world space. The connected entity must have at least a Transform2D component. If it also has a non-kinematic PhysicsBody2D, joint forces are also computed and applied to it. More...
 
FP Damper
 The damper capacity at which the spring oscillation is suppressed, in Newtons per square meter (N/m2). To get or set the damping RATIO, given the physics body(ies) involved, use GetStiffness and SetStiffness, respectively. More...
 
FP Distance
 The distance between the anchor points that the joint will attempt to maintain. More...
 
FP Spring
 The stiffness of the spring, in Newtons per meter (N/m). To get or set the frequency (Hz) at which the spring will attempt to oscillate, given the physics body(ies) involved, use GetStiffness and SetStiffness, respectively. More...
 

Detailed Description

A Joint that attaches a Physics Body to an anchor as if connected by a spring, trying to keep them a certain distance apart. The connected anchor can be a world-space position or another entity with at least a transform component.

Constructor & Destructor Documentation

◆ SpringJoint()

Quantum.Physics2D.SpringJoint.SpringJoint ( FP  spring,
FP  damper,
FP  distance,
EntityRef  connectedEntity,
FPVector2  anchor,
FPVector2  connectedAnchor 
)
inline

Constructs a SpringJoint struct. Use CreateJoint overloads instead to create a Joint of type JointType.SpringJoint.

Returns

Member Function Documentation

◆ CreateJoint() [1/2]

static Joint Quantum.Physics2D.SpringJoint.CreateJoint ( FP  spring,
FP  damper,
FP  distance,
EntityRef  connectedEntity = default,
FPVector2  anchor = default,
FPVector2  connectedAnchor = default 
)
inlinestatic

Creates a Joint of type JointType.SpringJoint.

Parameters
springThe stiffness of the spring, in Newtons per meter (N/m).
damperThe damping capacity at which the spring oscillation is suppressed, in Newtons per square meter (N/m2).
distanceThe distance between the anchor points that the joint will attempt to maintain.
connectedEntityA target entity that this joint might be connected to. If set to EntityRef.None, the ConnectedAnchor represents the target anchor position in world space. The connected entity must have at least a Transform2D component. If it also has a non-kinematic PhysicsBody2D, joint forces are also computed and applied to it.
anchorThe anchor offset, in the local space of the joint entity transform. This is the point considered for the joint constraints and where the joint forces are applied.
connectedAnchorIf the joint has a ConnectedEntity, this represents the anchor offset relative to it, in local space. Else, this is the position in world space considered as target anchor.
Returns
A Joint of type JointType.SpringJoint.

◆ CreateJoint() [2/2]

static Joint Quantum.Physics2D.SpringJoint.CreateJoint ( FP  frequency,
FP  dampingRatio,
FP  distance,
PhysicsBody2D *  jointBody,
EntityRef  connectedEntity = default,
PhysicsBody2D *  connectedBody = null,
FPVector2  anchor = default,
FPVector2  connectedAnchor = default 
)
inlinestatic

Creates a 2D Physics2D.Joint of type JointType.SpringJoint.

Parameters
frequencyThe frequency in Hertz (Hz) at which the spring joint will attempt to oscillate, given the mass of the body(ies) involved. Typical values are below half the frequency of the simulation.
dampingRatioA dimensionless value representing the damper capacity of suppressing the spring oscillation, typically between 0 and 1.
distanceThe distance between the anchor points that the joint will attempt to maintain.
jointBodyThe PhysicsBody2D component of the joint entity. The body mass affects the spring rate necessary to achieve the target oscillation frequency.
connectedEntityA target entity that this joint might be connected to. If set to EntityRef.None, the ConnectedAnchor represents the target anchor position in world space. The connected entity must have at least a Transform2D component. If it also has a non-kinematic PhysicsBody2D, joint forces are also computed and applied to it.
connectedBodyThe PhysicsBody2D component of the connectedEntity , if it exists and has one. Can be null, in which case the spring/damper rates will be computed as if the joint is connected to a fixed point or kinematic body.
anchorThe anchor offset, in the local space of the joint entity transform. This is the point considered for the joint constraints and where the joint forces are applied.
connectedAnchorIf the joint has a ConnectedEntity, this represents the anchor offset relative to it, in local space. Else, this is the position in world space considered as target anchor.
Returns
A Joint of type JointType.SpringJoint.

◆ GetStiffness()

void Quantum.Physics2D.SpringJoint.GetStiffness ( PhysicsBody2D *  jointBody,
PhysicsBody2D *  connectedBody,
out FP  frequency,
out FP  dampingRatio 
)
inline

Computes the frequency and dampingRatio based on the joint Spring and Damper capacities, given the physics body(ies) involved.

Parameters
jointBodyThe PhysicsBody2D component of the joint entity. The body mass affects the resultant oscillation frequency, given the joint spring stiffness.
connectedBodyThe PhysicsBody2D component of the entity connected to the joint, if it exists and has one. Can be null, in which case the frequency and damping ratio will be computed as if the joint is connected to a fixed point or kinematic body.
frequencyThe frequency in Hertz (Hz) at which the spring joint will attempt to oscillate, given the mass of the body(ies) involved. Typical values are below half the frequency of the simulation.
dampingRatioA dimensionless value representing the damper capacity of suppressing the spring oscillation, typically between 0 and 1.
Exceptions
NullReferenceExceptionIf the jointBody is null.

◆ SetStiffness()

void Quantum.Physics2D.SpringJoint.SetStiffness ( FP  frequency,
FP  dampingRatio,
PhysicsBody2D *  jointBody,
PhysicsBody2D *  connectedBody = null 
)
inline

Computes and sets the Spring and Damper capacities based on the target frequency and dampingRatio , given the physics body(ies) involved.

Parameters
jointBodyThe PhysicsBody2D component of the joint entity. The body mass affects the resultant oscillation frequency, given the joint spring stiffness.
connectedBodyThe PhysicsBody2D component of the entity connected to the joint, if it exists and has one. Can be null, in which case the frequency and damping ratio will be computed as if the joint is connected to a fixed point or kinematic body.
frequencyThe frequency in Hertz (Hz) at which the spring joint will attempt to oscillate, given the mass of the body(ies) involved. Typical values are below half the frequency of the simulation.
dampingRatioA dimensionless value representing the damper capacity of suppressing the spring oscillation, typically between 0 and 1.
Exceptions
NullReferenceExceptionIf the jointBody is null.

◆ ComputeStiffness()

static void Quantum.Physics2D.SpringJoint.ComputeStiffness ( FP  frequency,
FP  dampingRatio,
PhysicsBody2D *  jointBody,
PhysicsBody2D *  connectedBody,
out FP  spring,
out FP  damper 
)
inlinestatic

Computes the spring and damper capacities based on the target frequency and dampingRatio , given the physics body(ies) involved.

Parameters
jointBodyThe PhysicsBody2D component of the joint entity. The body mass affects the resultant oscillation frequency, given the joint spring stiffness.
connectedBodyThe PhysicsBody2D component of the entity connected to the joint, if it exists and has one. Can be null, in which case the frequency and damping ratio will be computed as if the joint is connected to a fixed point or kinematic body.
frequencyThe frequency in Hertz (Hz) at which the spring joint will attempt to oscillate, given the mass of the body(ies) involved. Typical values are below half the frequency of the simulation.
dampingRatioA dimensionless value representing the damper capacity of suppressing the spring oscillation, typically between 0 and 1.
Exceptions
NullReferenceExceptionIf the jointBody is null.

Member Data Documentation

◆ Anchor

FPVector2 Quantum.Physics2D.SpringJoint.Anchor

The anchor offset, in the local space of the joint entity transform. This is the point considered for the joint constraints and where the joint forces are applied.

◆ ConnectedAnchor

FPVector2 Quantum.Physics2D.SpringJoint.ConnectedAnchor

If the joint has a ConnectedEntity, this represents the anchor offset relative to it, in local space. Else, this is the position in world space considered as target anchor.

◆ ConnectedEntity

EntityRef Quantum.Physics2D.SpringJoint.ConnectedEntity

A target entity that this joint might be connected to. If set to EntityRef.None, the ConnectedAnchor represents the target anchor position in world space. The connected entity must have at least a Transform2D component. If it also has a non-kinematic PhysicsBody2D, joint forces are also computed and applied to it.

◆ Spring

FP Quantum.Physics2D.SpringJoint.Spring

The stiffness of the spring, in Newtons per meter (N/m). To get or set the frequency (Hz) at which the spring will attempt to oscillate, given the physics body(ies) involved, use GetStiffness and SetStiffness, respectively.

◆ Damper

FP Quantum.Physics2D.SpringJoint.Damper

The damper capacity at which the spring oscillation is suppressed, in Newtons per square meter (N/m2). To get or set the damping RATIO, given the physics body(ies) involved, use GetStiffness and SetStiffness, respectively.

◆ Distance

FP Quantum.Physics2D.SpringJoint.Distance

The distance between the anchor points that the joint will attempt to maintain.