|
This is what I wrote so far, but I it's erroring so obviously i'm doing it wrong.
script.Parent.Rot.Changed:connect(function()
local A, B, Rot = script.Parent.A, script.Parent.B, script.Parent.Rot
local PA = CFrame.new(A.CFrame + Vector3.new(0, (A.Size.Y/2 + 0.2) + B.Size.Y/2, 0))
B.CFrame = CFrame.new(PA) * CFrame.Angles(0, math.rad(Rot.Value), 0)
end)
The idea behind it was supposed to be that I'm creating a fake knee without additional parts except the shin and the thigh. Using CFrame to create a pivot point for the shin to create a cframe animation.
What am I doing wrong, and how do I fix it? |
|
|
19:43:18.916 - Workspace.Model.Script:4: bad argument #1 to 'new' (Vector3 expected, got CFrame)
19:43:18.916 - Script 'Workspace.Model.Script', Line 4
19:43:18.917 - Stack End
except that i did use a vector3 |
|
|
script.Parent.Rot.Changed:connect(function()
local A, B, Rot = script.Parent.A, script.Parent.B, script.Parent.Rot
B.CFrame = (A.CFrame + Vector3.new(0, A.Size.Y/2 + B.Size.Y/2 + 0.2, 0))
* CFrame.Angles(math.rad(Rot.Value), 0, 0)
end)
Works kinda. I got it to stay in place like a real leg, but the shin merely rotates in place rather than pivoting like a joint. I'm just not getting the math right. |
|
|
I feel like I need to CFrame the shin by offsetting it from the thigh by half the thigh's size.Y/2, rotate, then offset it again from it's new position by the shin itself's size.Y/2
It sounds logical to me but i don't know how to do that. So far everything I've done that i havent posted either gives me the same results or causes the shin's cframe to position it in wild locations around workspace. |
|
|
script.Parent.Rot.Changed:connect(function()
local A, B, Rot = script.Parent.A, script.Parent.B, script.Parent.Rot
B.CFrame = (A.CFrame + Vector3.new(0, A.Size.Y/2 + 0.2, 0))
* CFrame.Angles(math.rad(Rot.Value), 0, 0)
B.CFrame = B.CFrame + Vector3.new(0, B.Size.Y/2, 0)
end)
This is my newest attempt and this is the only thing that makes any sense to me but it isn't working. The shin is still rotating in one spot. It's not pivoting at all. |
|
|
script.Parent.Rot.Changed:connect(function()
local A, B, Rot = script.Parent.A, script.Parent.B, script.Parent.Rot
B.CFrame = (A.CFrame + Vector3.new(0, A.Size.Y/2 + 0.2, 0))
* CFrame.Angles(math.rad(Rot.Value), 0, 0)
B.CFrame = B.CFrame * CFrame.new(0, B.Size.Y/2, 0)
end)
nailed it. lol... ty for all the help. you people are so amazing. |
|
NickyJ3Join Date: 2011-12-23 Post Count: 3563 |
I'm sorry. If I could script advanced things, I would help you.
~Storm~ |
|
|
script.Parent.Rot.Changed:connect(function()
local A, B, Rot = script.Parent.A, script.Parent.B, script.Parent.Rot
B.CFrame = (A.CFrame * CFrame.new(0, A.Size.Y/2 + 0.2, 0))
* CFrame.Angles(math.rad(Rot.Value), 0, 0)
B.CFrame = B.CFrame * CFrame.new(0, B.Size.Y/2, 0)
end)
Fixed. I was using vector, not cframe. that was my problem. |
|
|
lol don't worry john. i'm just being sarcastic |
|