|
| 23 Mar 2015 05:19 PM |
Trying to get a block to point where the mouse is, but I need it to rotate solely on the Y axis. The block rotates randomly and doesn't point to the mouse however. And if I try to use CFrame instead of an Objectvalue, everything freaks and flies away!?
mouse.Move:connect(function() local dir=(mouse.Hit.lookVector) script.Parent.Parent.ObjectValue.Value.C0 = script.Parent.Parent.ObjectValue.Value.C0 * CFrame.Angles(0,dir.x,0) end)
|
|
|
| Report Abuse |
|
|
|
| 23 Mar 2015 05:47 PM |
Did you know joints (welds and such) work on object-space and not world-space? For instance,
CFrame.new(0,1,0) on C0 does NOT mean position 0,1,0. It means 0,1,0 offset from Part0. So setting C0 to
C0 = CFrame.new(0,1,0)
Is the same as setting a brick's position to:
Brick.Position = Weld.Part0.Position + Vector3.new(0,1,0)
Get what I'm saying? Also, please do not use C0 unless you are using rotate joints (Rotate, RotateP, RotateV). For welds, use C1 to adjust Part1. Here's how you do what you want.
mouse.Move:connect(function() local Weld = script.Parent.Parent.ObjectValue.Value; Weld.C1 = (CFrame.new(Weld.Part1.Position, mouse.Hit.p)):toObjectSpace(Weld.Part0.CFrame * Weld.C0); end)
|
|
|
| Report Abuse |
|
|
|
| 23 Mar 2015 07:11 PM |
The block faces the mouse now, but it doesn't rotate on a single axis. Also can you help explain what this does? (Weld.Part0.CFrame * Weld.C0) |
|
|
| Report Abuse |
|
|
|
| 23 Mar 2015 07:22 PM |
My bad, I forgot about that part:
mouse.Move:connect(function() local Weld = script.Parent.Parent.ObjectValue.Value; Weld.C1 = (CFrame.new(Weld.Part1.Position, Vector3.new(mouse.Hit.p.x,Weld.Part1.Position.Y,mouse.Hit.p.z))):toObjectSpace(Weld.Part0.CFrame * Weld.C0); end) |
|
|
| Report Abuse |
|
|