R15 Character Scaling

Alright. Who broke character scaling. This is a key mechanic in this game and it was working fine before… Heads and hats won’t scale now.

4 Likes

Going to need more information here, scaling is working fine in my testing place.

2 Likes

Sorry for not previously providing more details, thought it was site-wide.

Looks like it effects characters differently. I’m not sure why. I went to visit my game and found other players who had found all badges, which lets you shrink on command. My head never got scaled. The person to my right got everything scaled but their hats, and the person on the left got everything scaled but lost his hats.

The code is rather dead simple.

event.OnServerEvent:connect(function(player)
game.Workspace:findFirstChild(player.Name).Humanoid:findFirstChild(‘BodyDepthScale’).Value = 0.23
game.Workspace:findFirstChild(player.Name).Humanoid:findFirstChild(‘BodyWidthScale’).Value = 0.23
game.Workspace:findFirstChild(player.Name).Humanoid:findFirstChild(‘BodyHeightScale’).Value = 0.23
game.Workspace:findFirstChild(player.Name).Humanoid:findFirstChild(‘HeadScale’).Value = 0.23
game.Workspace:findFirstChild(player.Name).Humanoid.HipHeight = 0.37
end)

2 Likes

The man and woman heads don’t scale with the head part

I don’t think hats scale with HeadScale (yet?)

2 Likes

The game didn’t have these issues last week at all. Every single player lost their hats and had their heads scaled, including my “Man” head. Previously the default specialmesh head would scale TOO tiny though.

Now regular heads are scaling fine, hats are sometimes not scaling, sometimes disappearing and some heads aren’t scaling at all.

1 Like

Accessories being dropped wasn’t intended. Currently character scaling doesn’t scale accessories any smaller (we may add this later). I would recommend scaling the accessories manually for now. I will add a code sample for how to do this to the wiki later.

There was a bug fix for the default head being scaled too small and this seems to have introduced another bug where the other heads are not being scaled at all, we will fix this.

2 Likes

I’ve been using character scaling almost like a mechanic, where you need to be small to get into secret/hidden places that a normal sized player can’t fit in. Sooo…

Should I delete all accessories when I scale my characters for now, so their hats don’t block them from going places? Or are all accessories can’t-collide?

Edit: I guess I’ll be deleting them anyway considering they don’t scale… I’d almost rather them just fall off like they did last week, because anybody using character scaling is going to be doing this too?

1 Like

Any word on this? Just spent some time debugging why my avatar was able to ragdoll in play solo but @Simbuilder’s avatar wasn’t, and it turned out the reason was he had a duplicate Root joint in his avatar and I didn’t. Tested on the same machine, same test file, by setting Player.CharacterAppearance.

1 Like

Will fix, we are in code freeze until the end of the year though so this bug fix will be in the first client release of 2017.

3 Likes

Alright, thanks for the status update!

For anyone that needs this fixed in their games, I’ve been using this to get around it (after I figure out what the problem is at least):

--CharacterAdded in server script:
local rigHeight = character:WaitForChild("Humanoid"):WaitForChild("BodyHeightScale")
wait(1)
rigHeight.Value = rigHeight.Value + 1
rigHeight.Value = rigHeight.Value - 1

Changing the rig height forces the joints to rebuild, removing the duplicate ones. Without the wait it doesn’t work. wait() without the 1 or spawn may work also, and doing it clientside may correct the issue as well. I haven’t put too much effort into a clean solution since I mostly just need it for testing purposes and not for a live game, so you may want to modify it to be more elegant for your purposes (and make sure to post back here with results!)

1 Like

Can you post code for scaling hats relative to head size on R15?
I tried doing it myself, but my values for everything that’s not a “Hat” are a little off. It’d help a lot with anyone scaling R15 between now and 2017.

1 Like

Sorry, I meant to post this code a few days ago.

function findFirstMatchingAttachment(model, name)
	for _, child in pairs(model:GetChildren()) do
		if child:IsA("Attachment") and child.Name == name then
			return child
		elseif not child:IsA("Accoutrement") and not child:IsA("Tool") then -- don't look in hats or tools in the character
			local foundAttachment = findFirstMatchingAttachment(child, name)
			if foundAttachment then
				return foundAttachment
			end
		end
	end
end

local function getOriginalScale(handle)
	local origScaleValue = handle:FindFirstChild("OriginalScale")
	if not origScaleValue then
		origScaleValue = Instance.new("Vector3Value")
		origScaleValue.Name = "OriginalScale"
		origScaleValue.Value = handle.Size
		origScaleValue.Parent = handle
	end
	return origScaleValue.Value
end

local function findHandleMesh(handle)
	for _, obj in pairs(handle:GetChildren()) do
		if obj:IsA("DataModelMesh") then
			return obj
		end
	end
end

local function getAccoutrementWeld(attachmentPart, handle)
	local accessoryWeld = handle:FindFirstChild("AccessoryWeld")
	if accessoryWeld then
		return accessoryWeld, accessoryWeld.Parent
	end
	
	-- Legacy case
	for _, obj in pairs(attachmentPart:GetChildren()) do
		if obj:IsA("Weld") then
			if obj.Part0 == handle or obj.Part1 == handle then
				return obj, obj.Parent
			end
		end
	end

	return nil
end

local function rescaleAccessories(character, bodyScaleVector, headScale)
	local humanoid = character:FindFirstChildOfClass("Humanoid")
	for _, obj in pairs(character:GetChildren()) do
		if obj:IsA("Accoutrement") then
			local handle = obj:FindFirstChild("Handle")
			if handle then
				local originalSize = getOriginalScale(handle)
				local currentScaleVector = handle.Size/originalSize
				local desiredScaleVector = bodyScaleVector
				
				local accoutrementAttachment = handle:FindFirstChildOfClass("Attachment")
				local characterAttachment = accoutrementAttachment and findFirstMatchingAttachment(character, accoutrementAttachment.Name) or nil
				local attachmentPart = characterAttachment and characterAttachment.Parent or character:FindFirstChild("Head")
				
				if attachmentPart then
					if attachmentPart.Name == "Head" then
						desiredScaleVector = Vector3.new(headScale, headScale, headScale)
					end
					local modifyVector = desiredScaleVector/currentScaleVector

					local accoutrementWeld, oldParent = getAccoutrementWeld(attachmentPart, handle)					
					accoutrementWeld = accoutrementWeld and accoutrementWeld:Clone() or nil -- Weld will be broken when scaling, create a new one
					
					handle.Size = handle.Size * modifyVector
					local handleMesh = findHandleMesh(handle)
					if handleMesh then
						handleMesh.Scale = handleMesh.Scale * modifyVector
					end
					
					if accoutrementAttachment then
						-- Accessory case is easier
						accoutrementAttachment.Position = accoutrementAttachment.Position * modifyVector
					end
					-- Legacy hat logic case
					local x, y, z, R00, R01, R02, R10, R11, R12, R20, R21, R22 = obj.AttachmentPoint:components()
					obj.AttachmentPoint = CFrame.new(x*modifyVector.x, y*modifyVector.y, z*modifyVector.z, R00, R01, R02, R10, R11, R12, R20, R21, R22)
	
					local attachmentCFrame = characterAttachment and characterAttachment.CFrame or CFrame.new(0, 0.5*headScale, 0)
					local hatCFrame = accoutrementAttachment and accoutrementAttachment.CFrame or obj.AttachmentPoint

					if accoutrementWeld then
						accoutrementWeld.Parent = oldParent
						if oldParent == handle then
							accoutrementWeld.C0 = hatCFrame
							accoutrementWeld.C1 = attachmentCFrame
						else
							accoutrementWeld.C0 = attachmentCFrame
							accoutrementWeld.C1 = hatCFrame
						end
					end
				end
			end
		end
	end
end

-- Used like this, call after re-scaling the character with the new scale values.
rescaleAccessories(game.Workspace.Player1, Vector3.new(0.75, 2, 1), 1)
9 Likes

Howdy Guys ; I am truly thankful , glad and honored to be Finally a member of this forum :smiley:

I only wanted to Inform my fellow developers here that I probably made the very First R15 Morphing system and the very First free ; really working and reliable ; constraints based R15 Ragdoll death system :smiley:

You guys can fell free to update and Improve my stuff ; Especially my Ragdoll death isn’t working with custom character scales and Packages ->So pls can someone update it ?

Also beware you might get a stroke from viewing my scripts , but I am just a unexperienced beginner ^^


8 Likes

It seems this is still a problem @TheGamer101

2 Likes

I will fix this, thanks for the report.

2 Likes

This is the best.

2 Likes

Could this happen at some point? I asked a couple people who don’t play ROBLOX which looked better and more comfortable to play as, and they all said the 1.2-tal character is best.

4 Likes