Allow Parts to be resized without breaking Motor6Ds

One of the biggest annoyances I’ve ran into while scaling limbs on characters, is the fact that I have to keep reconnecting the limbs because the joints break when you change the size of the part.

I can understand why this is in place for things like a Snap, but I don’t think it makes any sense for it to break Motor6D joints.
Just imagine the ability to rescale a player’s arm using the studio tool, whilst keeping its shoulder joint in-tact. That would be awesome.

2 Likes

It’s because resizing changes the position. How are you supposed to intelligently change the position of the motor? Which do we change, the C0 or the C1? Do we change resize behavior for motored parts? It’s a difficult problem.

True.
Though what if I was to simply change the size with code without necessarily changing the position?

True.
Though what if I was to simply change the size with code without necessarily changing the position?[/quote]
I dunno, you could write a plugin that does all this fancy stuff for you rather than putting the burden of figuring out proper behavior on the engine.

You change the C1. The C0 is the attachment point, the C1 is the offset from the attachment point.

1 Like

You change the C1. The C0 is the attachment point, the C1 is the offset from the attachment point.[/quote]

It might seem that simple, but what if someone expects it to change the C0? Or what if they expect the Part0 to move with it? What really is the best solution, and what are the criteria to find it?

You change the C1. The C0 is the attachment point, the C1 is the offset from the attachment point.[/quote]

It might seem that simple, but what if someone expects it to change the C0? Or what if they expect the Part0 to move with it? What really is the best solution, and what are the criteria to find it?[/quote]

And why do we need to change the C0/C1 in the first place?

Because then it doesn’t act like normal resizing does.

Act like normal resizing. Preserve the C0 by moving the other part. Change the C1 to account for the change in the part’s position.

You change the C1. The C0 is the attachment point, the C1 is the offset from the attachment point.[/quote]

It might seem that simple, but what if someone expects it to change the C0? Or what if they expect the Part0 to move with it? What really is the best solution, and what are the criteria to find it?[/quote]

If I expect the transparency to change by setting the Reflectance property then that’s my own fault. C0 and C1 could be named better, sure, but the purpose of them is that C0 is the attachment point and C1 is the offset. You can see this in hats, gear, and even the default character joints. It is expected behavior.

I don’t see why they’d expect Part0 to move if they explicitly select Part1 and explicitly drag the arrows.

That would be some inverse kinematics business.

If you’re resizing a character, you will have to change both C0 and C1.

Why should the C0/C1 be changing when resizing in the first place?

1 Like

If the C0 and C1 don’t change, the part will be resized on its center instead of on the side.

If the C0 and C1 don’t change, the part will be resized on its center instead of on the side.[/quote]

Is that problematic?
If a part is connected to another part with a joint, I don’t want that joint changing unless I tell it to.

If the C0 and C1 don’t change, the part will be resized on its center instead of on the side.[/quote]

Is that problematic?
If a part is connected to another part with a joint, I don’t want that joint changing unless I tell it to.[/quote]

Problem here is that you expect it to resize from the edge

I expected spheres and cylinders to resize from the edge too. I was pretty mad when they didn’t (and also when they had a plus-half offset on the dragger grid.)

Look I feel like I let this post drift into the wrong direction.

Here is what Im trying to say.

Lets say I wanted to scale a character by multiplying the size and cframe offsets by 2. Currently when the size of a part changes, the motor is destroyed.
The biggest problem with this is that when the connection between the head and the torso is broken, the Humanoid just dies.

I want to be able to change the size of a part without the connection between Motor6Ds breaking. This behavior should not even apply when using the resize tool, it should just apply to when the size is changed with code. I dont want the C0 or C1 to change at all, when I can just do that myself using some transforming. So the resize tool would still break motors, but code wouldn’t.

Does that make more sense? :stuck_out_tongue:

[quote] Look I feel like I let this post drift into the wrong direction.

Here is what Im trying to say.

Lets say I wanted to scale a character by multiplying the size and cframe offsets by 2. Currently when the size of a part changes, the motor is destroyed.
The biggest problem with this is that when the connection between the head and the torso is broken, the Humanoid just dies.

I want to be able to change the size of a part without the connection between Motor6Ds breaking. This behavior should not even apply when using the resize tool, it should just apply to when the size is changed with code. I dont want the C0 or C1 to change at all, when I can just do that myself using some transforming. So the resize tool would still break motors, but code wouldn’t.

Does that make more sense? :stuck_out_tongue: [/quote]
Hi there.

[spoiler][code]
– Character resize

local Player = game.Players.LocalPlayer
local Char = Player.Character
local Humanoid = Char.Humanoid

function GetMesh(Obj)
for i,v in pairs(Obj:GetChildren()) do
if v:IsA(“DataModelMesh”) then
return v
end
end
end

function SaveWelds(Obj,Welds,Scale)
if Welds == nil then
local Welds = {}
for i,v in pairs(Obj:GetChildren()) do
if v:IsA(“JointInstance”) then
Welds[#Welds+1] = {v,v.Part0,v.Part1,v.C0,v.C1,v.Parent}
v.Parent = nil
end
SaveWelds(v,Welds,Scale)
end
return Welds
else
for i,v in pairs(Obj:GetChildren()) do
if v:IsA(“JointInstance”) then
Welds[#Welds+1] = {v,v.Part0,v.Part1,v.C0,v.C1,v.Parent}
v.Parent = nil
end
SaveWelds(v,Welds,Scale)
end
end
end

function SaveConnectedParts(Obj,Welds)
if Welds == nil then
local Welds = {}
for i,v in pairs(Obj:GetChildren()) do
if v:IsA(“BasePart”) then
for i2,v2 in pairs(v:GetConnectedParts()) do
Welds[#Welds+1] = {Instance.new(“Weld”),v,v2,v.CFrame:toObjectSpace(v2.CFrame),CFrame.new(0,0,0),v}
end
v:BreakJoints()
end
SaveConnectedParts(v,Welds)
end
return Welds
else
for i,v in pairs(Obj:GetChildren()) do
if v:IsA(“BasePart”) then
for i2,v2 in pairs(v:GetConnectedParts()) do
Welds[#Welds+1] = {Instance.new(“Weld”),v,v2,v.CFrame:toObjectSpace(v2.CFrame),CFrame.new(0,0,0),v}
end
v:BreakJoints()
end
SaveConnectedParts(v,Welds)
end
end
end

function ResizeWelds(Welds,Scale)
for i,v in pairs(Welds) do
v[1].Parent = v[6]
v[1].Part0 = v[2]
v[1].Part1 = v[3]
local Vec = v[4].p
local Vec2 = v[5].p
v[1].C0 = CFrame.new(VecScale)(v[4]-Vec)
v[1].C1 = CFrame.new(Vec2Scale)(v[5]-Vec2)
end
end

function ResizeFunc(Obj,Scale,Welds)
for i,v in pairs(Obj:GetChildren()) do
if v:IsA(“BasePart”) then
local Size = v.Size
for i2,v2 in pairs(v:GetChildren()) do
if v2.Name == “ScaleInserted” then
Size = Sizev2.Scale
v2:Destroy()
elseif v2.Name:sub(1,14) == “ScaleInserted:” then
local X,Y,Z;
for Match in v2.Name:sub(15):gmatch(“[^,%s]+”) do
if Y ~= nil then
Z = tonumber(Match)
elseif X ~= nil then
Y = tonumber(Match)
else
X = tonumber(Match)
end
end
Size = Vector3.new(X,Y,Z)
v2:Destroy()
end
end
v.FormFactor = “Custom”
local CFr = v.CFrame
local Want = Size
Scale
v.Size = Want
if v.Size ~= Want then
local Name = “”
for Match in v.Name:gmatch(“[^%s]+”) do
Name = Name…Match
end
local CharMesh = nil
for i,v in pairs(Obj:GetChildren()) do
if v:IsA(“CharacterMesh”) and tostring(v.BodyPart):sub(15) == Name then
CharMesh = v
end
end
if CharMesh == nil then
local Mesh = GetMesh(v)
if Mesh == nil then
local Mesh;
if v:IsA(“WedgePart”) then
Mesh = Instance.new(“SpecialMesh”,v)
Mesh.MeshType = “Wedge”
else
if v.Shape == “Ball” then
Mesh = Instance.new(“SpecialMesh”,v)
Mesh.MeshType = “Sphere”
elseif v.Shape == “Cylinder” then
Mesh = Instance.new(“SpecialMesh”,v)
Mesh.MeshType = “Cylinder”
else
Mesh = Instance.new(“BlockMesh”,v)
end
end
Mesh.Scale = Want/v.Size
Mesh.Name = “ScaleInserted”
else
if (Mesh.ClassName == “SpecialMesh” and Mesh.MeshType ~= Enum.MeshType.FileMesh) or Mesh.ClassName ~= “SpecialMesh” then
Mesh.Scale = Want/v.SizeMesh.Scale
end
end
else
local Mesh = Instance.new(“SpecialMesh”,v)
Mesh.Name = “ScaleInserted:”…tostring(Want)
Mesh.MeshType = “FileMesh”
Mesh.MeshId = “rbxassetid://”…CharMesh.MeshId
–Mesh.TextureId = CharMesh.BaseTextureId – Was too lazy to implement character mesh textures. Sorry.
Mesh.Scale = Vector3.new(1,1,1)Want.X/Scale
end
end
–v.CFrame = CFrame.new(CFr.p
Scale)
(CFr-CFr.p) – Not so good for characters, but for non-jointed objects it’s good.
elseif v:IsA(“DataModelMesh”) then
if v.ClassName == “SpecialMesh” then
if v.MeshType == Enum.MeshType.FileMesh then
v.Scale = v.Scale*Scale
end
end
end
ResizeFunc(v,Scale,Welds)
end
end

function Resize(Obj,Scale)
local Welds = SaveWelds(Obj,nil,Scale)
SaveConnectedParts(Obj,Welds)
ResizeFunc(Obj,Scale,Welds)
ResizeWelds(Welds,Scale)
Humanoid.CameraOffset = Vector3.new(0,Char.HumanoidRootPart.Size.Y/2+Char.Head.Size.Y/2-1.5,0)
Humanoid.WalkSpeed = Humanoid.WalkSpeedScale
Humanoid.MaxHealth = Humanoid.MaxHealth
Scale
wait(0.25) – i cri cuz the Health script interferes.
Humanoid.Health = Humanoid.Health*Scale – And it still doesn’t always play nicely.
end

Player.Chatted:connect(function(m)
if m:sub(1,3) == ";s " then
local Scale = tonumber(m:sub(4))
if Scale then
if (Char.Head.Size*Scale).Z < 0.4 then – Animations act all wonky when you get pretty small.
Char.Animate.Disabled = true – Unfortunately, any animations that were playing when you did this will keep playing.
– A hacky fix for this is to remove the old humanoid and put a new one in, but then the character won’t respawn when they die.
else
Char.Animate.Disabled = false
end
Resize(Char,Scale)
end
end
end)
[/code][/spoiler]

I agree with Clone
Changing a part’s size should change nothing but the part’s size.

Should changing a Weld’s C0 change the part’s size too, then? :stuck_out_tongue:

1 Like