Class Utility
Static class that contains various extension methods.
Namespace: Unity.Kinematica
Syntax
public static class Utility
Methods
GetAnalogInput(Single, Single)
Combines two floating point values into a float2 value.
Declaration
public static float3 GetAnalogInput(float x, float y)
Parameters
Type | Name | Description |
---|---|---|
Single | x | The horizontal value; expected to be in the range -1 to 1. |
Single | y | The vertical value; expected to be in the range -1 to 1. |
Returns
Type | Description |
---|---|
float3 | The corresponding float2 value. |
Remarks
Normalizes the resulting float2 value if the magnitude is greater than 1.0.
GetDesiredForwardDirection(float3, float3)
Converts a world space vector into a relative vector w.r.t. the current main camera.
Declaration
public static float3 GetDesiredForwardDirection(float3 absoluteLinearVelocity, float3 forwardDirection)
Parameters
Type | Name | Description |
---|---|---|
float3 | absoluteLinearVelocity | The world space vector to be converted. |
float3 | forwardDirection | The default forward direction, used if the linear velocity is zero. |
Returns
Type | Description |
---|---|
float3 | The converted view-direction relative vector. |
GetDesiredForwardDirection(float3, float3, float3)
Converts a world space vector into a relative vector.
Declaration
public static float3 GetDesiredForwardDirection(float3 absoluteLinearVelocity, float3 forwardDirection, float3 cameraForward)
Parameters
Type | Name | Description |
---|---|---|
float3 | absoluteLinearVelocity | The world space vector to be converted. |
float3 | forwardDirection | The default forward direction, used if the linear velocity is zero. |
float3 | cameraForward | The view direction to be used for the conversion. |
Returns
Type | Description |
---|---|
float3 | The converted view-direction relative vector. |
GetRelativeLinearVelocity(float3, float3)
Converts a world space vector into a view-direction relative vector.
Declaration
public static float3 GetRelativeLinearVelocity(float3 absoluteLinearVelocity, float3 normalizedViewDirection)
Parameters
Type | Name | Description |
---|---|---|
float3 | absoluteLinearVelocity | The world space vector to be converted. |
float3 | normalizedViewDirection | The normalized view direction. |
Returns
Type | Description |
---|---|
float3 | The converted view-direction relative vector. |
Remarks
For a third-person controller it is common to convert a 3d-vector into a representation that is relative to a camera. This method takes as input a normalized view direction (e.g. the forward vector of a camera transform) and converts a vector passed as argument into a vector that is relative to the view direction.
SampleTrajectoryAtTime(MemoryArray<AffineTransform>, Single, Single)
Declaration
public static AffineTransform SampleTrajectoryAtTime(MemoryArray<AffineTransform> trajectory, float sampleTimeInSeconds, float timeHorizon)
Parameters
Type | Name | Description |
---|---|---|
MemoryArray<AffineTransform> | trajectory | |
Single | sampleTimeInSeconds | |
Single | timeHorizon |
Returns
Type | Description |
---|---|
AffineTransform |