I am trying to point the arms to a specific point in the world, and that i want to do by modifying the motor6d’s in the rig.
I know that a motor6d works like this part0.CF*C0 is where the motor6d is. then part1.CF is offseted by C1.
so iv’e been making this script
local folder = script.Parent
local target = workspace.TT
--local Parts = {folder.Start, folder.Middle, folder.End}
local bias = (HumaoidRootPart.CFrame * CFrame.new(0,-10, 0)).Position
local targetPos = target.Position
local Bases = {cLeftShoulder, cLeftElbow, cLeftHand}
local Sizes = {UpperArmLenght, LowerArmLenght, 0}
--Bases[1] left shoulder motor6d
while true do
deb.step()
--deb.CFrame(Bases[1].Part0.CFrame * Bases[1].C0)
local CF = Bases[1].Part0.CFrame * Bases[1].C0
Bases[1].C1 = CFrame.new(Bases[1].C1.Position, CF:VectorToObjectSpace(target.Position))
deb.CFrame(CF * Bases[1].C1)
task.wait()
end
you can get the angle that will make the arm look at a part by doing
local direction = Cframe.new(YourArmPosition,ThePartToLookAtPosition)
arm.CFrame = direction
That’s my bad, I forgot the CFrame constructor had multiple prototypes.
Just to make sure, what happens if you simply do Bases[1].C1 = CFrame.new(Vector3.zero, Bases[1].C0:VectorToObjectSpace(target.Position))?
It would be great to start off with the arm pointing in the right direction.
Weird, can you do deb.CFrame(CFrame.new(Bases[1].C0:VectorToObjectSpace(target.Position)))? Assuming that is what renders those XYZ axes in the screenshots.
I made an error where that debug point was basically useless because C0 was probably equal to a blank CFrame, so it was taking a vector in world space and converting it to the workspace’s local space (aka also world space, lol)
I find it weird that the shoulder is only rotating along the Y axis and not any other. I can’t think of anything else right now so I’d say just keep throwing things at it until something works.
Hello
The solution was as easy as a 12th grade mathematics problem
So we know as i’ve said in the last post that we have this equation part1.CF * C1 = Part0.CF * C0
But keep in mind that the CFrame operations are not comutative; that means that CF1 * CF2 (CF1 ofsetted by CF2 amount) is not the same as CF2 * CF1 (CF2 offsetted by CF1 amount)
So the solution for C1 is the following C1 = part1.CF:Inverse() * Part0.CF * C0
It means that you can now input any CFrame you want the arm in this case to part1.CF and you will have the motor6d C1 calculated for you