Hello im trying to figure out how to modify the scale of a certain bone with scripting. What i want to do is essentially that if a bool becomes true, then “BoneX” will increase its scaling in X and Z, but not in Y. i havent found any command or any way to scale bones in unity and google searchs hasnt provided any answers other than scaling bones its the best practice, but for now its what i need.
You could try something like this. Then simply reference one of the bones in the inspector.
For constant scaling.
public GameObject bone;
public float ScaleRate = 2;
bool scale = false;
void Update()
{
if (scale)
{
Vector3 boneScale = bone.transform.localScale;
boneScale.x += ScaleRate * Time.DeltaTime;
boneScale.z += ScaleRate * Time.DeltaTime;
bone.transform.localScale = boneScale;
}
Alternatively if you want to simply increase the scale a certain amount you could do something like this:
public GameObject bone;
public float scaleSizeX, scaleSizeZ, originalSizeX, originalSizeZ;
bool scale = false;
void Start()
{
originalSizeX = bone.transform.localScale.x;
originalSizeZ = bone.transform.localScale.z;[/INDENT]
}
void Update()
{
if (scale)
{
Vector3 boneScale = bone.transform.localScale;
boneScale.x += scaleSizeX;
boneScale.z += scaleSizeZ;
bone.transform.localScale = boneScale;[/INDENT]
}
else
{
Vector3 boneScale = bone.transform.localScale;
boneScale.x += originalSizeX;
boneScale.z += originalSizeZ;
bone.transform.localScale = boneScale;
}
Did that help?
1 Like
Nice, im gonna try it when im home, i think this is exactly what i needed!! thanks.
Here’s the full solution - Body Proportions