I am trying to use a BallSocketConstraint with an IKControl object to animate a character to look at a point. I want to use a constraint to prevent the waist from moving about too much.The issue I’m running to is that the BallSocketConstraint refuses to work!
Here is how I’m setting it up with code
local function CreateAttachment(name: String, parent: Attachment, cframe: CFrame?)
local attachment = Instance.new("Attachment")
attachment.Name = name
if cframe then
attachment.CFrame = cframe
end
attachment.Parent = parent
return attachment
end
local function CreateConstraint(name: String, type: String, attachment0: Attachment, attachment1: Attachment, parent)
local constraint = Instance.new(type)
constraint.Name = name
constraint.Attachment0 = attachment0
constraint.Attachment1 = attachment1
constraint.Parent = parent
return constraint
end
function CharacterPivotController:StartAnimation(character: Model)
self.Animating = true
self.Character = character
local waistAttachment0 = CreateAttachment("WaistConstraintAttachment0", character.LowerTorso.WaistRigAttachment, CFrame.new())
local waistAttachment1 = CreateAttachment("WaistConstraintAttachment1", character.UpperTorso.WaistRigAttachment, CFrame.new())--*CFrame.Angles(0,0,math.rad(90)))
local constraint = CreateConstraint("WaistConstraint", "BallSocketConstraint", waistAttachment0, waistAttachment1, character.UpperTorso)
constraint.Enabled = true
constraint.LimitsEnabled = true
constraint.TwistLimitsEnabled = true
constraint.UpperAngle = 20
constraint.TwistUpperAngle = 20
constraint.TwistLowerAngle = -20
local ik = Instance.new("IKControl")
ik.Parent = character:FindFirstChildOfClass("Humanoid")
-- or "AnimationController" if your character has that
ik.Type = Enum.IKControlType.LookAt
ik.EndEffector = character:FindFirstChild("Head", true)
ik.ChainRoot = character:FindFirstChild("UpperTorso", true)
ik.Target = self.ikTarget
end
The active property of the ballsocketconstraint never turns on and the character ends up flopping about like a fish. Any help would be greatly appreciated!