Click or drag to resize

IJointUtilsSetupSphericalJoint Method

Sets up joint so what it becomes a spherical hinge joint.

Namespace:  KASAPIv2
Assembly:  KAS-API-v2 (in KAS-API-v2.dll) Version: KAS API v2
Syntax
C#
void SetupSphericalJoint(
	ConfigurableJoint joint,
	float springForce = 0f,
	float springDamperRatio = 0.1f,
	float maxSpringForce = ∞f,
	float angleLimit = ∞f,
	float angleLimitForce = 0f,
	float angleLimitDamperRatio = 0.1f
)
Request Example View Source

Parameters

joint
Type: UnityEngineConfigurableJoint
Joint to setup.
springForce (Optional)
Type: SystemSingle
Torque force to apply when joint angle deviates from the original.
springDamperRatio (Optional)
Type: SystemSingle
Percentage of the torque force to use for dampering oscillation effect.
maxSpringForce (Optional)
Type: SystemSingle
Maximum torque force to apply when joint angle deviates from the original.
angleLimit (Optional)
Type: SystemSingle
Maximum rotation angle (degrees) around Y or Z axis.
angleLimitForce (Optional)
Type: SystemSingle
Force to apply to keep joint in limits. If it's 0 then the limit is impassible.
angleLimitDamperRatio (Optional)
Type: SystemSingle
Percentage of the limit force to use for dampering oscillation effect.
Remarks

It's a standard PhysX configuration. Main axis is set to Z, and angular rotation around it is completely unrestricted. Secondary axes are X&Y can be restricted by applying spring force and/or limits. Drive mode is set to Position.

Only angular settings are set. If joint had linear constraints defined they will stay unchanged. Consider using ResetJoint(ConfigurableJoint) to eliminate side effects from the previous settings of the joint.

Pure spherical joint assumes 3 out of the 6 degrees of freedom to be locked (all the three axes linear motions). Consider setting enablePreprocessing to true since it may improve PhysX performance.

For performance reasons some parameters combinations may result in different angular modes:

  • When springForce is Infinite or angleLimit is 0 Y&Z rotation modes are set to Locked. If you plan to change force/limit don't forget to update the modes as well.
  • When springForce is 0 and angleLimit is Infinite Y&Z rotation modes are set to Free. If you plan to change either of the parameters don't forget to update the modes as well.

Regardless to the modes set all the other parameters are also applied. I.e. you don't need to re-apply them when changing mode.

See Also