Kinematics for Unity
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Properties | List of all members
Passer.Kinematics.LinearJoint Class Reference

Unity

A LinearJoint lets transforms move along a defined axis

Inspector

The range of motion can be limited by a minimum and maximum distance. Chains of (linear) joints can be created with support for inverse kinematics.

Scene

In the scene view, the axis and limits are visualized when the object is selected. The axis is a yellow line from the transform's position in the direction of the axis. When the joint has limits, the minimum and maximum distance are drawn as small speres at the end of the yellow line. The yellow line will then also be extended to the minumum and maximum values. The picture above shows a cube with a LinearJoint with a limit of -0.5 and 2 units.

Inverse Kinematics

Inverse kinematics is built-in and works when you have a kinematic chain of kinematic joints parented to each other. Only the last child should have a target assigned. Example:

Rotational Joint 1 [ target = null ]
-> Linear Joint 2 [ target = null ]
   -> Linear Joint 3 [ target != null ]

The target's movements of the end effector (Linear Joint 3 in the example) will then propagate up through the kinematic joints on the parent transforms. The kinematic joints do not have to be direct children of each other for this to work. Example:

Inheritance diagram for Passer.Kinematics.LinearJoint:
Passer.Kinematics.KinematicJoint

Public Member Functions

override void Update ()
 
override Vector3 CalculateTargetPosition ()
 
override void UpdateValue (float value)
 Update the position of this LinearJoint More...
 
override void CheckConstraints ()
 
Vector3 GetCorrectionVector ()
 
virtual void FindParentConstraint ()
 
virtual void DetermineBaseTargetVector (Vector3 targetPosition, Quaternion targetRotation, bool findParent=true, bool traverseWelds=true)
 
virtual void UpdateKinematics ()
 
virtual void UpdateInverseKinematics (KinematicJoint childJoint)
 
virtual void CleanupTransmissions ()
 Removes any transmissions which have an empty otherJoint More...
 
void AddTransmission (Transmission newTransmission)
 

Public Attributes

float maxSpeed = 1
 Maximum translation speed in units per second More...
 
float acceleration = 2
 Acceleration in units per second per second More...
 
GameObjectEventHandlers gameObjectEvents
 Event Handlers for the lifecycle of the GameObject More...
 
FloatEventHandlers distanceEvents
 Event handles based on the distance values More...
 
KinematicJoint parentJoint
 The parent constraint in a kinematic chain More...
 
bool hasLimits = false
 The movments relative to axis are limited More...
 
bool leading = true
 
Transform target
 The target Transform for the movements More...
 
Vector3 targetPosition = Vector3.zero
 
Quaternion targetRotation = Quaternion.identity
 
Vector3 axis = Vector3.up
 The local axis of the joint More...
 
KinematicJoint sourceJoint
 
Transmission[] transmissions
 

Protected Member Functions

override void CalculateTarget (Vector3 targetPosition, Quaternion targetRotation)
 
void UpdateForwardKinematics2 (Vector3 targetPosition, Quaternion targetRotation)
 
override void Actuate ()
 
float UpdateSpeed (float acceleration, float targetSpeed, float distance=-1)
 
override void UpdateTransmissionIK ()
 
override void TransmissionForward ()
 
virtual float GetTranslation ()
 
Vector3 GetLocalPosition ()
 
Vector3 GetWorldPosition (Vector3 localPosition)
 
override void UpdateEvents ()
 
Vector3 GetLocalVector (Vector3 worldVector)
 
virtual void Awake ()
 
PureGetComponentInChildren< T > ()
 
virtual void Start ()
 
virtual void LateUpdate ()
 
virtual void CheckTargetChange ()
 
Vector3 CalculateTargetPosition (Vector3 childTargetPosition)
 
virtual Quaternion CalculateTargetRotation (Vector3 parentPositionm, Quaternion targetRotation)
 
void RemoveTransmission (KinematicJoint kinematicJoint)
 
bool HasTransmission ()
 

Protected Attributes

Vector3 sollPosition
 
float currentSpeed
 
float distanceValue
 
IWeld weld = null
 
Vector3 baseVectorLocal = Vector3.zero
 
Quaternion baseRotation = Quaternion.identity
 The base rotation for the limites More...
 
Quaternion baseRotationLocal = Quaternion.identity
 
Vector3 basePosition = Vector3.zero
 The base position for the limits More...
 
Quaternion targetBaseRotation = Quaternion.identity
 The rotation of the target at start in world coordinates More...
 
float lastTargetJointAngle = 0
 

Properties

override float minimum [get, set]
 The minimum local position. More...
 
override float maximum [get, set]
 The maximum local position. More...
 
Vector3 targetVector [get]
 The vector from the transform position to the target in world coordinates More...
 
Vector3 baseVector [get]
 The vector from the transform to the target position at start in world coordinates More...
 
Vector3 worldAxis [get]
 The world axis of the joint More...
 

Member Function Documentation

◆ UpdateValue()

override void Passer.Kinematics.LinearJoint.UpdateValue ( float  value)
virtual

Update the position of this LinearJoint

Parameters
valueThe desired translation along the axis in units

Reimplemented from Passer.Kinematics.KinematicJoint.

◆ CleanupTransmissions()

virtual void Passer.Kinematics.KinematicJoint.CleanupTransmissions ( )
virtualinherited

Removes any transmissions which have an empty otherJoint

Member Data Documentation

◆ maxSpeed

float Passer.Kinematics.LinearJoint.maxSpeed = 1

Maximum translation speed in units per second

Note that the Inverse Kinematics can become unstable when this is set to high speeds

◆ acceleration

float Passer.Kinematics.LinearJoint.acceleration = 2

Acceleration in units per second per second

◆ gameObjectEvents

GameObjectEventHandlers Passer.Kinematics.LinearJoint.gameObjectEvents
Initial value:
= new GameObjectEventHandlers() {
label = "GameObject",
tooltip = "Call functions based on the GameObject life cycle",
id = 0,
eventTypeLabels = new string[] {
"Never",
"Start",
"On Destroy",
"Update",
" ",
" ",
" "
}
}

Event Handlers for the lifecycle of the GameObject

◆ distanceEvents

FloatEventHandlers Passer.Kinematics.LinearJoint.distanceEvents
Initial value:
= new FloatEventHandlers() {
label = "Distance",
tooltip =
"Call function using the X axis range value\n" +
"Parameter: the range along the X axis (-1..1)",
id = 1,
eventTypeLabels = new string[] {
"Never",
"On Min",
"On Max",
"While Min",
"While Max",
"On Change",
"Continuous"
},
}

Event handles based on the distance values

These are especially conventient for doing thinge when the minimum or maximum distance value has been reached

◆ parentJoint

KinematicJoint Passer.Kinematics.KinematicJoint.parentJoint
inherited

The parent constraint in a kinematic chain

◆ hasLimits

bool Passer.Kinematics.KinematicJoint.hasLimits = false
inherited

The movments relative to axis are limited

◆ baseRotation

Quaternion Passer.Kinematics.KinematicJoint.baseRotation = Quaternion.identity
protectedinherited

The base rotation for the limites

◆ basePosition

Vector3 Passer.Kinematics.KinematicJoint.basePosition = Vector3.zero
protectedinherited

The base position for the limits

◆ target

Transform Passer.Kinematics.KinematicJoint.target
inherited

The target Transform for the movements

The kinematic object tries to follow the target as far this is possible within the set constrains. For rotations: the target rotation is used when the target position is equal to the object position when the target is attached to the object. Otherwise the target position is used for rotations.

◆ targetBaseRotation

Quaternion Passer.Kinematics.KinematicJoint.targetBaseRotation = Quaternion.identity
protectedinherited

The rotation of the target at start in world coordinates

This will be identity when the target is not set. This will change when the target is changed

◆ axis

Vector3 Passer.Kinematics.KinematicJoint.axis = Vector3.up
inherited

The local axis of the joint

Property Documentation

◆ minimum

override float Passer.Kinematics.LinearJoint.minimum
getset

The minimum local position.

This localPosition is relative to the basePosition.

◆ maximum

override float Passer.Kinematics.LinearJoint.maximum
getset

The maximum local position.

This localPosition is relative to the basePosition.

◆ targetVector

Vector3 Passer.Kinematics.KinematicJoint.targetVector
getinherited

The vector from the transform position to the target in world coordinates

◆ baseVector

Vector3 Passer.Kinematics.KinematicJoint.baseVector
getinherited

The vector from the transform to the target position at start in world coordinates

This will be zero vector when the target is not set. This will change when the target is changed

◆ worldAxis

Vector3 Passer.Kinematics.KinematicJoint.worldAxis
getinherited

The world axis of the joint


The documentation for this class was generated from the following file: