How do I multiply a Cframe by a Vector3?

Multi is the players size (vector3) and when the player is a bigger size, the legs are inside of the chest, and when they are smaller, they are slightly in the floor. I’m trying to make it so that doesn’t happen

code:

function R6IK:LegIK(Side : "Left" | "Right", Position, Multi)
	if Side == "Left" then
		local OriginCF = self.Torso.CFrame*self.C0s["Left Hip"]
		local C1Off = self.C1s["Left Hip"]
		local PlaneCF,ShoulderAngle,ElbowAngle, l3 = SolveLegIK(OriginCF*CFrame.Angles(0, math.pi/2, 0), Position, self.LeftUpperLegLength, self.LeftLowerLegLength, C1Off)

		local HipAngleCFrame, KneeAngleCFrame = CFrame.Angles(ShoulderAngle, 0, 0), CFrame.Angles(ElbowAngle, 0, 0)

		local HipCF = PlaneCF * HipAngleCFrame*CFrame.new(0,-self.LeftUpperLegLength * 0.5,0)
		local KneeCF = HipCF*CFrame.new(0,-self.LeftUpperLegLength * 0.5,0)* KneeAngleCFrame * CFrame.new(0, -self.LeftLowerLegLength*0.5, 0)*CFrame.new(0,(self.LeftLeg.Size.Y-self.LeftLowerLegLength)*0.5,0)

		return WorldCFrameToC0ObjectSpace(self.Motor6Ds["Left Hip"], KneeCF, Multi)
	elseif Side == "Right" then
		local OriginCF = self.Torso.CFrame*self.C0s["Right Hip"]
		local C1Off = self.C1s["Right Hip"]
		local PlaneCF,ShoulderAngle,ElbowAngle, l3 = SolveLegIK(OriginCF*CFrame.Angles(0, -math.pi/2, 0), Position, self.RightUpperLegLength, self.RightLowerLegLength, C1Off)

		local HipAngleCFrame, KneeAngleCFrame = CFrame.Angles(ShoulderAngle, 0, 0), CFrame.Angles(ElbowAngle, 0, 0)

		local HipCF = PlaneCF * HipAngleCFrame*CFrame.new(0,-self.RightUpperLegLength * 0.5,0)
		local KneeCF = HipCF*CFrame.new(0,-self.RightUpperLegLength * 0.5,0)* KneeAngleCFrame * CFrame.new(0, -self.RightLowerLegLength*0.5, 0)*CFrame.new(0,(self.RightLeg.Size.Y-self.RightLowerLegLength)*0.5,0)

		return WorldCFrameToC0ObjectSpace(self.Motor6Ds["Right Hip"], KneeCF, Multi)
	end
end
local function WorldCFrameToC0ObjectSpace(motor6DJoint,worldCFrame,Multi)
	local part1CF = motor6DJoint.Part1.CFrame
	local part0 = motor6DJoint.Part0
	local c1Store = motor6DJoint.C1
	local c0Store = motor6DJoint.C0
	local relativeToPart0 = part0.CFrame:inverse() * worldCFrame * c1Store

	local goalC0CFrame = relativeToPart0
	
	return goalC0CFrame
end
2 Likes

Just pass it into CFrame.new().

Would be like this:

local goalC0CFrame = relativeToPart0 * CFrame.new(Multi)
1 Like

I have tried that. this is used for an IK animation script.

this is what happens when I do that

1 Like

still unsolved. I really need this to be fixed.

more of the code if needed:

function R6IK:LegIK(Side : "Left" | "Right", Position, Multi)
	if Side == "Left" then
		local OriginCF = self.Torso.CFrame*self.C0s["Left Hip"]
		local C1Off = self.C1s["Left Hip"]
		local PlaneCF,ShoulderAngle,ElbowAngle, l3 = SolveLegIK(OriginCF*CFrame.Angles(0, math.pi/2, 0), Position, self.LeftUpperLegLength, self.LeftLowerLegLength, C1Off)

		local HipAngleCFrame, KneeAngleCFrame = CFrame.Angles(ShoulderAngle, 0, 0), CFrame.Angles(ElbowAngle, 0, 0)

		local HipCF = PlaneCF * HipAngleCFrame*CFrame.new(0,-self.LeftUpperLegLength * 0.5,0)
		local KneeCF = HipCF*CFrame.new(0,-self.LeftUpperLegLength * 0.5,0)* KneeAngleCFrame * CFrame.new(0, -self.LeftLowerLegLength*0.5, 0)*CFrame.new(0,(self.LeftLeg.Size.Y-self.LeftLowerLegLength)*0.5,0)

		return WorldCFrameToC0ObjectSpace(self.Motor6Ds["Left Hip"], KneeCF, Multi)
	elseif Side == "Right" then
		local OriginCF = self.Torso.CFrame*self.C0s["Right Hip"]
		local C1Off = self.C1s["Right Hip"]
		local PlaneCF,ShoulderAngle,ElbowAngle, l3 = SolveLegIK(OriginCF*CFrame.Angles(0, -math.pi/2, 0), Position, self.RightUpperLegLength, self.RightLowerLegLength, C1Off)

		local HipAngleCFrame, KneeAngleCFrame = CFrame.Angles(ShoulderAngle, 0, 0), CFrame.Angles(ElbowAngle, 0, 0)

		local HipCF = PlaneCF * HipAngleCFrame*CFrame.new(0,-self.RightUpperLegLength * 0.5,0)
		local KneeCF = HipCF*CFrame.new(0,-self.RightUpperLegLength * 0.5,0)* KneeAngleCFrame * CFrame.new(0, -self.RightLowerLegLength*0.5, 0)*CFrame.new(0,(self.RightLeg.Size.Y-self.RightLowerLegLength)*0.5,0)

		return WorldCFrameToC0ObjectSpace(self.Motor6Ds["Right Hip"], KneeCF, Multi)
	end
end
1 Like

Your title doesn’t really explain anything. Why do you need to multiply the CFrame by Multi? What does Multi represent? Your code already returns a CFrame in object space of part0, so what is Multi supposed to do at this point? Are you sure that Multi itself is calculated correctly?

1 Like

I apologize. I made this post when I knew very little of what I needed to do, but now I understand a lot more of what I need to do.

Multi is the players size (vector3) and when the player is a bigger size, the legs are inside of the chest, and when they are smaller, they are slightly in the floor. I’m trying to make it so that doesn’t happen

1 Like

You can get the Vector3 position of your CFrame by doing yourCFrame.Position. You can compare that to the initial position before the player’s size change, and adjust accordingly.

1 Like

I don’t understand. Could you elaborate?

1 Like

Actually, I was rereading your question, you were having trouble with scaling the player correct?

I think ScaleTo() might work. Documentation

I’m sorry if this is unhelpful, I’m having trouble understanding what you are trying to fix.

1 Like