Runtime scaling

Overview


MagicaCloth2 supports scale changes at runtime.
However, scaling has some limitations.
This section explains the limitations and how to change the scale during execution.

Limitations


Only uniform scaling is currently supported.
That is, the overall scaling of the XYZ axes evenly by 2x, 3x, or 0.5x.
You cannot scale the XYZ axes separately.
Also, it does not support negative scale.
If you want to flip the character in a 2D game, etc., please rotate the Y axis 180 degrees.

Base scale


The scale value at which the cloth component is initialized at runtime is called the base scale.
MagicaCloth’s scale change is a little special, so that no matter what scale change you make at runtime, it will not change its base scale and how it sways.

For example, the following three characters are centered at base scale, left at 1.5x, and right at 0.7x.

You can see that the shaking is exactly the same even if the size changes.
As you can see, the scale at initialization is very important.

Scale change method


There are some caveats when actually changing the scale of a character.

Cannot scale before initialization

Any run-time scaling should be done after the cloth component is initialized.
Changing the scale before initialization will result in unintended behavior.
Cloth component initialization is done with Awake().
So if you want to do scale changes in the same Awake(), you have to manually call the cloth component initialization.
Use Initialize() for this.

However, this limitation can be circumvented by using pre-construction.
For information on pre-building, see Using pre-building.

Precautions when placing in the scene in advance

For example, let’s say you have a character prefab A with a cloth component.
Please note that if you place this prefab A in the scene from the beginning with the scale doubled, it will not work well.
This is because the base scale is determined at the time of initialization, so this character will be treated as the base scale when the scale is doubled.
In such a case, it is necessary to place it in the scene without changing the scale, and change the scale after initializing the component with a script or the like.

However, this limitation can be circumvented by using pre-construction.
For information on pre-building, see Using pre-building.