Skip to content

CCDIKClass API

TBD


Constructor

new(table Motor6DTable, dictionary Constraints)

Constructs the CCDIK Controller given a table of Motor6D Instances in order.

local leftLegController = CCDIKController.new(Motor6DTable,Constraints)

The constraints can be manually inputted using the following template, though it's more recommended to use the :GetConstraints() and :GetConstraintsFromMotor() function to do it automatically instead.

Constraints Dictionary Template
local hipJoint = Instance.new("Motor6D")-- Motor6D within the Rig
local kneeJoint = Instance.new("Motor6D")
local constraintsTemplate = {
    [kneeJoint] = {
        ["ConstraintType"] = "Hinge";
        ["UpperAngle"] = 45; -- same as HingeConstraint [-180,180] degrees
        ["LowerAngle"] = -45;
        ["AxisAttachment"] = nil; --Automatically tries to find first child an attachment with the part0Motor6dName..AxisAttachment
        ["JointAttachment"] = nil; --or you can manually input it
    };
    [hipJoint] = {
        ["ConstraintType"] = "BallSocketConstraint";
        ["UpperAngle"] = 45; -- same as BallSocketConstraint [-180,180] degrees
        ["TwistLimitsEnabled"] = false ; -- yep same as roblox constraints
        ["TwistUpperAngle"] = 45; 
        ["TwistLowerAngle"] = -45;
        ["AxisAttachment"] = nil; --Automatically tries to find first child during .new() setup but you can manually input it
        ["JointAttachment"] = nil;
    };
}
--Example with the Mech in the test place, not necessary to fill everything out
local constraints = {
    [upperLeg] = {
        ["ConstraintType"] = "BallSocketConstraint";
        ["UpperAngle"] = 25;
        ["AxisAttachment"] = "LeftHip";--Searches for "LeftHipAxisAttachment" in the part0 of the motor
    };
    [lowerLeg] = {
        ["ConstraintType"] = "Hinge";
        ["UpperAngle"] = 45;
        ["LowerAngle"] = -45;
    };
    [knee] = {
        ["ConstraintType"] = "Hinge";
        ["UpperAngle"] = 45;
        ["LowerAngle"] = -45;
    };
}

Properties

dictionary Constraints

The dictionary containing the attachments instances and information of the UpperAngle and LowerAngles


bool LerpMode

Bool to disable or enable Motor6D lerping, by default it's true.


number LerpAlpha

Default lerp alpha inputted into the CFrame:Lerp of the Motor6D iteration from the current orientation towards the goal orientation.


bool ConstantLerpSpeed

Enabled constant speed lerping


number AngularSpeed

Speed of the constant speed lerping, default is 90 degrees


Methods

GetConstraints()


GetConstraintsFromMotor(motor : Motor6D ,constraintName : string)


CCDIKIterateOnce(goalPosition,tolerance,step)


CCDIKIterateUntil(goalPosition,tolerance,maxBreakCount,step)


SetupFoot(attachmentNameTable : table,raycastParams)


InitDragDebug()