amanda
|
  |
| Joined: 21 Nov 2006 |
| Total Posts: 5925 |
|
|
| 17 Mar 2015 06:48 PM |
| What is the simplest way to weld all the parts in a model to each other, a collection of parts grouped together, wanting to save their positions and rotations relative to each other? |
|
|
| Report Abuse |
|
|
IoIiderp
|
  |
| Joined: 05 Feb 2012 |
| Total Posts: 8613 |
|
| |
|
kert109
|
  |
| Joined: 31 Dec 2009 |
| Total Posts: 681 |
|
|
| 17 Mar 2015 06:53 PM |
mainP = bla
for i, v in pairs(ThatModelYouWant:children())
Weld = Instance.new("Weld",mainP) Weld.Part0 = mainP Weld.Part1 = v Weld.C0 = mainP.CFrame:toObjectSpace(v.CFrame) -- if this doesn't work, switch mainP.CFrame and v.CFrame. end
|
|
|
| Report Abuse |
|
|
amanda
|
  |
| Joined: 21 Nov 2006 |
| Total Posts: 5925 |
|
|
| 17 Mar 2015 07:00 PM |
that makes all the parts seemingly welded to each other, but also cframed into the exact same position, so all the parts in the model have the same position, and i don't want that
i want them to keep their positions relative to each other, that sort of sandwiches them :O |
|
|
| Report Abuse |
|
|
amanda
|
  |
| Joined: 21 Nov 2006 |
| Total Posts: 5925 |
|
|
| 17 Mar 2015 07:06 PM |
| It works if I anchor it all. |
|
|
| Report Abuse |
|
|
|
| 17 Mar 2015 07:40 PM |
@Kert
Two problems
1) Ew, you used C0. Bad practice when C0 is mainly reserved for swing joints 2) You need to set the C1 before setting the parts, unless parented afterwards Xtra 3) Also, :toObjectSpace turns the preceding CFrame to the space of the one in parenthesis, don't just guess :P
--- Solution
local Main; -- Don't touch for i, v in pairs(ThatModelYouWant:GetChildren()) if (not Main) then Main = v else local Weld = Instance.new("Weld",game.JointsService) Weld.C1 = v.CFrame:toObjectSpace(Main.CFrame); Weld.Part0 = Main Weld.Part1 = v end end
|
|
|
| Report Abuse |
|
|
amanda
|
  |
| Joined: 21 Nov 2006 |
| Total Posts: 5925 |
|
|
| 17 Mar 2015 07:44 PM |
| DrMathematica, thanks so much. |
|
|
| Report Abuse |
|
|
| |
|
kert109
|
  |
| Joined: 31 Dec 2009 |
| Total Posts: 681 |
|
|
| 17 Mar 2015 08:01 PM |
" Weld.C1 = v.CFrame:toObjectSpace(Main.CFrame); Weld.Part0 = Main Weld.Part1 = v "
Amg, I just remembered I had this problem last time and that's how I fixed.
And who defines "bad practice" of using C0? |
|
|
| Report Abuse |
|
|
|
| 17 Mar 2015 08:04 PM |
"And who defines "bad practice" of using C0?"
It's logically viewed as bad practice because it serves a key point in other joint objects such as Rotates (hinges, motors, stepping motors). Why? Ever tried making an NPC with Motors or Motor6Ds?
You can't rely solely on C0 to do it, because you need that to create a center point for pivotal swinging, while C1 will be used to offset Part1.
Don't reply with "Well it doesn't matter in this case" because I've heard that a thousand times. It's true, it doesn't, but it's bad practice to misuse a property. Doesn't mean it's wrong. |
|
|
| Report Abuse |
|
|
|
| 17 Mar 2015 08:10 PM |
| It's usually easiest to keep C0 as CFrame.new() and use only C1 except for certain cases with motors. Since joints on Roblox have Part0 follow Part1, it makes more sense to set C1 so that you're calculating relative to Part1 rather than Part0. |
|
|
| Report Abuse |
|
|