Hi RainyRizzle, I hope you are fine! I want to report a bug. When making an animation clip, I create a new keyframe for a layer and set its scaling value to -1. In this way, I can get the mirror of the object/layer.
In my animation clip there is a character in the middle. And there is a flying object near the character (left side at start). I move the object on the left to the right with the animation. But I need to get mirror of this layer after moving to the left to the right. When I set the scaling value to -1, this happens successfully.
Mirroring (scale -1) works fine in AnyPortrait preview. However, the in the game/runtime does not work properly. After the scaling value is -1, the object is hidden. This is a bug and I would appreciate it if you fix it.
This issue was encountered in AnyPortrait 1.4.3.
Unity 2021.3.17f1 LTS
Thanks in advance!
By default, AnyPortrait's meshes are rendered only on the front side like other 3D models.
In the AnyPortrait editor, it is always drawn normally even if the scale of the mesh is reversed, but in the Unity Scene, it may not be visible depending on the Bake setting or Shader.
If you applied a Transform modifier to the mesh to invert its scale, it would probably show up in the Unity Scene without doing anything special.
This is because AnyPortrait detects the Scale of a Mesh or Sub-MeshGroup and converts their front/back surfaces in real time.
However, this does not apply to Morph or Rigging.
In the case of Morph or Rigging, when determining the reversal of the scale, it is not possible to determine the front/back side because "some vertices" are targeted rather than the entire mesh.
There are 4 ways to solve this problem.
1. The first is to make the mesh "two-sided".
Making the mesh render indistinguishable from front/back will easily solve this problem.
This method can reduce graphics performance because the number of rendered vertices is doubled.
Check out the following manual on how to make a mesh two-sided.
2. The second method can be applied in the case of rigging.
If you invert the scale of a bone, as explained above, it may not render because the front/back faces of the mesh are unknown.
In this case, you can simply solve the problem through the Bake option.
Change the value of "Bake Dialog > Setting Tab > Flipped Mesh" to "Check All".
And when Bake is done, the front/back side will be determined by recognizing the scale value of the bone to which the meshes are connected.
A detailed explanation can be found on the following page.
If "only some of the bones' scales are inverted" among the bones connected to the mesh, the shape of the mesh is greatly distorted and it is difficult to distinguish the front/back side.
In this case, you need to make the mesh two-sided using the method (1).
3. The following method is a variation of the method of (1), that is, the method of rendering both sides, and is to create a custom shader.
To create a custom shader and render the back side as well, set the shader's cull option to "Off".
Check the Unity manual for the cull option.
(However, since Cull Off is only used in special cases, we do not recommend it as it can cause other problems.)
4. The last method, if you want to invert the scale of the whole character.
This is the approach we use in other projects that actually use AnyPortrait.
The best way to invert the scale of the entire character during animation is not to invert the character within AnyPortrait, but to invert the scale of the GameObject in the Unity Scene by writing a script.
In other words, if you reverse the sign of Scale of Transform of GameObject with apPortrait or its parent GameObject after Bake, you will be able to invert the size of both the character and several sub-objects.
If you only want to change the size for a certain amount of time during an animation, using an "Animation Event" may help you.
AnyPortrait not only provides various approaches related to scale as above, but also optimizes performance.
Making Scale negative in Unity causes DrawCall to increase, but AnyPortrait manages to keep DrawCall as long as possible.
It may be helpful to read the following article as a reference.
If the above answers didn't solve your problem, please leave a comment!
If you let us know what kind of object you scaled (Bone or Mesh), we will be able to pinpoint the problem.