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
Properties
allChainsHaveTargets
Returns true if all chains in the Solver have 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
Gets and sets the 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 and set restoring default pose before the update.
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 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
Type | Name | Description |
---|---|---|
List<Vector3> | targetPositions | Target position for the chain. |
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 of the 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 | 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()
OnValidate()
Validate and initialize the Solver.
Declaration
protected virtual void OnValidate()
UpdateIK(List<Vector3>, Single)
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. |
Single | globalWeight | Weight for position solving. |
UpdateIK(Single)
Perform the Solver IK update.
Declaration
public void UpdateIK(float globalWeight)
Parameters
Type | Name | Description |
---|---|---|
Single | globalWeight | Weight for position solving. |