AnyPortrait > Manual > Creating a character in multiple directions

Creating a character in multiple directions


1.3.4

When creating the characters that appear in the game, depending on the game, you may need to make them face the front, the side, and the back.
This type of work is often used in top-view games as well as side-view action games.
This page covers how to use AnyPortrait to create a character that looks in multiple directions.


Please note that this description focuses on the functions and does not cover the detailed process of making animations or how to draw images.


There are two main ways to create a character with a multi-directional appearance.
The first method is to create multiple root units and convert it into a script.
Another way is to create one root unit with multiple child mesh groups and control it with a control parameter.
Each has pros and cons, so choose the one that works for you from the descriptions below.








Method 1. Using Multiple Root Units




The first way to create a character facing multiple directions is to create root units for each direction.
Unless you're making complex animations such as switching directions in the middle of a motion, this method is pretty intuitive and easy to script.




The prepared mesh groups and root units are "Front", "Side" and "Back" as above.
Each mesh group is independent of each other.




Each mesh group that becomes the root unit has bones and a "Rigging modifier" and a "Transform (Animation) modifier".




Animations are also made for each direction.
(1) Create an animation "Walk_Front" for "Front".
(2) Connect this animation to the "Front" mesh group.
(3) Make the animation for the front mesh group.






In the same way, create animations for "Side" and "Back".


Now let's write a simple script to change the direction of the character.



Looking at the script, there is no separate code to switch the root unit, just the code to play animations.
The root unit is switched according to the animation, so you can write the code really simple.




Let's put the character and the script into the Unity scene.
(1) Bake the character in the AnyPortrait editor, place it in the scene.
(2) Create a new GameObject.
(3) Add the script to the created GameObject and assign apPortrait.




Run the game and press the number 1, 2, 3 keys as we wrote in the script to switch to the corresponding root unit and run the animation.


Using multiple root units is not much different from the existing production method, you can just write a script to play animations that match the direction of the character.
The advantage of this approach is that the workflow and scripting are easy and intuitive.
On the other hand, the disadvantage is that it is difficult to create a motion that switches directions.
If you want to create an animation that switches directions, you need to write a script to play animations for each direction in order.
With these characteristics, this method can be effectively used in top-view games.




Method 2. Using Multiple Child Mesh Groups




The second method is to add "child mesh groups" as sub objects to "the root mesh group that become the root unit".
You can make only the child mesh group that need to be rendered visible, and hide the rest of the mesh groups so that the character's direction changes.
(1) The character looks the same as the previous description, but 3 mesh groups are registered as sub objects in one mesh group.
(2) Each mesh group has independently meshes and bones, and "Rigging modifier" is applied.




When working with creating parent-child mesh groups, you need to decide which modifier to add to which mesh group.
This is especially important if the child mesh groups each have a bone and move independently.
We recommend configuring modifiers as above.


Considering the ease of work, consistency, and performance, it is recommended to add Morph, Transform, Color Only modifiers to the root mesh group.
In particular, Animation modifiers can only be added to the root mesh group.
(If you accidentally add the Animation modifier to a child mesh group and create an animation, please refer to the related page to solve it.)


Rigging, Physics modifiers work regardless of external data (control parameters, animations), so it might be more convenient to add them to the child mesh group with bones or meshes.
Adding a Rigging modifier to the child mesh group can be convenient for you to work with, especially if the child mesh group has bones.
However, please be careful, as a problem occurs when more than one Rigging modifier is applied to the target mesh.
It is ok to add these modifiers to the parent mesh group and apply them.


It is possible to add Controller modifiers (Morph, Transform, Color Only) to a child mesh group, but we do not recommend it.
In our experience, complex registration of modifiers to parent-child mesh groups has resulted in problems with unintended movement.
Therefore, it is recommended to edit the deformation by external data consistently in the root mesh group if possible.




The most important point in this approach is to "switch the child mesh group shown using the control parameter".
This corresponds to switching the root unit by running the animation in the first way above.
(1) Add a new control parameter. We created a control parameter named "Root Pose".
(2) Set the control parameter type to Int.
(3) We set the range of values from -1 to 1, to map them to "Back: -1", "Side: 0", "Front: 1" respectively.




(1) Select the root mesh group.
(2) Select the Modifier tab and click the Add Modifier button.
(3) Select the "Color Only (Controller)" modifier and (4) press the Select button.




(1) Register 3 keys in the control parameter.
(2) Register the child mesh groups in the modifier.




Makes the visible child mesh group be changed according to the control parameter.
When the value is -1, it is set to show the "Back", "Side" is shown when it is 0, "Front" is shown when it is 1.
You can now change the direction of the character by controlling the "Root Pose" control parameter.




Before explaining the subsequent process, if you use multiple child mesh groups, please check the description of the following functions first.








Let's create the bone animation.
(1) Select the root mesh group and click the Add Modifier button in the Modifier tab.
(2) Select the Transform (Animation) modifier and (3) press the Select button.




(1) Add a new animation.
(2) After setting the animation a name, click the Select Mesh Group button.
(3) Mesh groups appear, you can see that child mesh groups that cannot be root units cannot be selected. Select the root mesh group.
(4) Press the Select button.




(1) Click the Add Timeline button.
(2) Add a Control Parameters timeline to switch child mesh groups.




(1) Select the added Control Parameters timeline.
(2) Select the "Root Pose" control parameter created earlier.
(3) Click the Add Timeline Layer to Edit button to register the control parameter in the timeline.




(1) Click the Add Timeline button again.
(2) To create a bone animation, select Modifier: Transform (Animation) and add it.




(1) Select the added Transform (Animation) timeline.
(2) Select the Bones tab.
(3) Click the All Bones to Layers button.
(4) Click the Okay button in the message to register all bones in the timeline.




Now let's make the bone animation.
Before making the bone animation, let's set keyframes to show or hide the child mesh group, i.e. the direction of the character.
(Depending on your style, you may be able to edit the visibility of the mesh group and the bone animation at the same time, contrary to the description on this page.)
(1) Turn on the Edit mode, and select “Root Pose” in the Control Parameters timeline.
(2) Add keyframes.




(1) Select Keyframe and (2) specify the value of the control parameter.
(3) As above, we set a keyframe so that "Front > Side > Back > Side" is displayed repeatedly.
(4) If you play the animation, you can see that the direction of the character changes according to the value of "Root Pose" in the workspace.




The next step is to create a bone animation.
(1) Select the Transform (Animation) timeline and turn on the Edit mode.
(2) However, in this state, the "Root Pose" control parameter is not applied, so all mesh groups are displayed in the workspace.




The method described earlier on this page solves this problem.
(1) Enable View Menu > Edit Mode Options > Apply Multiple Modifiers if no conflict (shortcut: D ).




Now the timeline that is not currently being edited works, so only child mesh groups that fit the current state are shown in the workspace.




Currently, the bones are set to not be visible in the workspace.
Let's make the bones visible by pressing the  B  button or by turning on the View menu > Show Bones.
However, all bones are shown independently of the rendering state of the child mesh groups.
Too many bones are cluttered up in the workspace, making it difficult to edit.




Let's use Visibility Preset.
(1) Select View menu > Visibility Preset > Settings.




(1) Add a new rule.
(2) Set the method of this rule to "Show Bones If Mesh Group Visible".
This option causes the bones to be rendered in the workspace only when the mesh group they belong to is rendered.




Apply the created rule.
(1) Select the created rule in View menu > Visible Preset and (2) click Enable Preset to activate it. (Shortcut key: I )
(3) When the animation is played, only the bones for the child mesh group that are visible are shown in the workspace.




Now that everything is ready, it's time to create the bone animation.
Within an animation clip, you can create motion to make a character move while changing direction.


This process will be different depending on what motion your character has and how you animate it.
Even so, the following explanations will help you as you create motions.




(1) Select the Transform timeline and timeline layers, create keyframes, and (2) modify the character's pose.




(1) Create keyframes just before the character's direction changes.
(2) Modify the pose as closely as possible to the next pose of the character.




When the character's direction changes by moving to the next frame, the smaller the difference in pose from the previous frame, the more natural the animation.


If the positions of the last keyframes in the previous character direction and the first keyframes in the next direction are the same, the transition will be more natural.




By combining the bone animation and the control parameters, we created an animation that looks like a character rotating as above.
If you add more keyframes, Morph modifier, and proper character images suitable for rotation, you will be able to create a much higher quality work.


Setting the control parameters and poses so that the character's direction transitions naturally takes a lot of know-how.
In addition to our description of the features, try creating your own animations to gain a lot of experience and create great creations.




Let's check the finished character animation in the Unity scene.
(1) On the screen where the root unit is selected, select Animation Clip and activate Auto Play to make the animation play automatically.
(2) Execute Bake.




You should see the finished animation playing in the Unity scene.


The way to use multiple child mesh groups is to edit many objects at the same time as shown in the description.
The inevitable cons are that the workflow is rather difficult and there are a lot of things that need to be set up.
However, overcoming these difficulties has a huge advantage in being able to represent a change in character direction within a single animation.
This is a good technique for creating complex motions in side-view action games, such as characters running, fighting, jumping and turning around.