Class Solver2D
Abstract class for implementing a 2D IK Solver.
Inherited Members
Namespace: UnityEngine.U2D.IK
Syntax
[MovedFrom("UnityEngine.Experimental.U2D.IK")]
public abstract class Solver2D : MonoBehaviour, IPreviewable
Properties
allChainsHaveTargets
Returns true if all chains in the Solver has a target.
Declaration
public bool allChainsHaveTargets { get; }
Property Value
Type | Description |
---|---|
Boolean |
chainCount
Returns the number of IKChain2D in the solver.
Declaration
public int chainCount { get; }
Property Value
Type | Description |
---|---|
Int32 |
constrainRotation
Get Set for rotation constrain property.
Declaration
public bool constrainRotation { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
isValid
Returns true if the Solver2D is in a valid state.
Declaration
public bool isValid { get; }
Property Value
Type | Description |
---|---|
Boolean |
solveFromDefaultPose
Get Set for restoring default pose.
Declaration
public bool solveFromDefaultPose { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
weight
Get and Set Solver weights.
Declaration
public float weight { get; set; }
Property Value
Type | Description |
---|---|
Single |
Methods
DoInitialize()
Override to perform 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> effectorPositions)
Parameters
Type | Name | Description |
---|---|---|
List<Vector3> | effectorPositions | Position of the effectors. |
DoValidate()
Override to perform custom validation.
Declaration
protected virtual bool DoValidate()
Returns
Type | Description |
---|---|
Boolean | Returns true if the Solver is in a valid state. False otherwise. |
GetChain(Int32)
Override to return the IKChain2D at the given index.
Declaration
public abstract IKChain2D GetChain(int index)
Parameters
Type | Name | Description |
---|---|---|
Int32 | index | Index for IKChain2D. |
Returns
Type | Description |
---|---|
IKChain2D |
GetChainCount()
Override to return the number of chains in the Solver
Declaration
protected abstract int GetChainCount()
Returns
Type | Description |
---|---|
Int32 | Integer represents IKChain2D count. |
GetPlaneRootTransform()
Override to return the root Unity Transform of the Solver. The default implementation returns the root transform of the first chain.
Declaration
protected virtual Transform GetPlaneRootTransform()
Returns
Type | Description |
---|---|
Transform | Unity Transform that represents 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 coordinate
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 coordinate. |
Initialize()
Initializes the solver.
Declaration
public void Initialize()
OnPreviewUpdate()
Empty method. Implemented for the IPreviewable interface.
Declaration
public void OnPreviewUpdate()
OnValidate()
Validate and initialize the Solver.
Declaration
protected virtual void OnValidate()
UpdateIK(List<Vector3>, Single)
Perform Solver IK update.
Declaration
public void UpdateIK(List<Vector3> positions, float globalWeight)
Parameters
Type | Name | Description |
---|---|---|
List<Vector3> | positions | Positions of chain. |
Single | globalWeight | Weight for position solving. |
UpdateIK(Single)
Perform Solver IK update.
Declaration
public void UpdateIK(float globalWeight)
Parameters
Type | Name | Description |
---|---|---|
Single | globalWeight | Weight for position solving. |