Class Solver2D
Abstract class for implementing a 2D IK Solver.
Inherited Members
Namespace: UnityEngine .U2D.IK
Assembly: Unity.2D.IK.Runtime.dll
Syntax
[MovedFrom("UnityEngine.Experimental.U2D.IK")]
public abstract class Solver2D : MonoBehaviour
Properties
allChainsHaveTargets
Returns true if all chains in the Solver have a target.
Declaration
public bool allChainsHaveTargets { get; }
Property Value
Type | Description |
---|---|
bool |
chainCount
Returns the number of IKChain2D in the solver.
Declaration
public int chainCount { get; }
Property Value
Type | Description |
---|---|
int |
constrainRotation
Gets and sets the rotation constrain property.
Declaration
public bool constrainRotation { get; set; }
Property Value
Type | Description |
---|---|
bool |
isValid
Returns true if the Solver2D is in a valid state.
Declaration
public bool isValid { get; }
Property Value
Type | Description |
---|---|
bool |
solveFromDefaultPose
Get and set restoring default pose before the update.
Declaration
public bool solveFromDefaultPose { get; set; }
Property Value
Type | Description |
---|---|
bool |
weight
Get and Set Solver weights.
Declaration
public float weight { get; set; }
Property Value
Type | Description |
---|---|
float |
Methods
DoInitialize()
Override to initialize the solver.
Declaration
protected virtual void DoInitialize()
DoPrepare()
Override to prepare the solver for update.
Declaration
protected virtual void DoPrepare()
DoUpdateIK(List<Vector3>)
Override to perform Solver IK update.
Declaration
protected abstract void DoUpdateIK(List<Vector3> targetPositions)
Parameters
DoValidate()
Override to perform custom validation.
Declaration
protected virtual bool DoValidate()
Returns
Type | Description |
---|---|
bool | Returns true if the Solver is in a valid state. False otherwise. |
GetChain(int)
Override to return the IKChain2D at the given index.
Declaration
public abstract IKChain2D GetChain(int index)
Parameters
Type | Name | Description |
---|---|---|
int | index | Index of the IKChain2D. |
Returns
Type | Description |
---|---|
IKChain2D | A chain at a given index. |
GetChainCount()
Override to return the number of chains in the Solver.
Declaration
protected abstract int GetChainCount()
Returns
Type | Description |
---|---|
int | Number of chains in the solver. |
GetPlaneRootTransform()
Override to return the root transform of the Solver. The default implementation returns the root transform of the first chain.
Declaration
protected virtual Transform GetPlaneRootTransform()
Returns
Type | Description |
---|---|
Transform | Transform representing the root. |
GetPointOnSolverPlane(Vector3)
Convert a world position coordinate to the solver's plane space.
Declaration
protected Vector3 GetPointOnSolverPlane(Vector3 worldPosition)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | worldPosition | Vector3 representing world position |
Returns
Type | Description |
---|---|
Vector3 | Converted position in solver's plane |
GetWorldPositionFromSolverPlanePoint(Vector2)
Convert a position from solver's plane to world coordinates.
Declaration
protected Vector3 GetWorldPositionFromSolverPlanePoint(Vector2 planePoint)
Parameters
Type | Name | Description |
---|---|---|
Vector2 | planePoint | Vector3 representing a position in the Solver's plane. |
Returns
Type | Description |
---|---|
Vector3 | Converted position to world coordinates. |
Initialize()
Initializes the solver.
Declaration
public void Initialize()
OnPreviewUpdate()
Empty method. Implemented for the IPreviewable interface.
Declaration
public void OnPreviewUpdate()
OnValidate()
Validate new values set from the Inspector.
Declaration
protected virtual void OnValidate()
UpdateIK(List<Vector3>, float)
Perform the Solver IK update with specified target positions.
Declaration
public void UpdateIK(List<Vector3> targetPositions, float globalWeight)
Parameters
Type | Name | Description |
---|---|---|
List<Vector3> | targetPositions | Target positions. |
float | globalWeight | Weight for position solving. |
UpdateIK(float)
Perform the Solver IK update.
Declaration
public void UpdateIK(float globalWeight)
Parameters
Type | Name | Description |
---|---|---|
float | globalWeight | Weight for position solving. |