Contents
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.
However, in the future, we plan to support flip scale on the XYZ axis.
For example, it is a function that can invert the X axis by setting the X axis to a negative scale.
This is useful for flipping characters in 2D games, etc.
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.
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.