docs.unity3d.com
    Show / Hide Table of Contents

    Class Solver2D

    Abstract class for implementing a 2D IK Solver.

    Inheritance
    Object
    Solver2D
    CCDSolver2D
    FabrikSolver2D
    LimbSolver2D
    Namespace: UnityEngine.U2D.IK
    Syntax
    public abstract class Solver2D : MonoBehaviour

    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()

    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)

    Perfom Solver IK update.

    Declaration
    public void UpdateIK(float globalWeight)
    Parameters
    Type Name Description
    Single globalWeight

    Weight for position solving.

    Back to top
    Terms of use
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023