AnyPortrait > Manual > Place on 3D World
AnyPortrait is basically an editor for 2D games.
However, it is also supported for various game methods such as introducing 2D character in 3D background.
This page describes how to render characters created with AnyPortrait in the Perspective camera used in 3D games and how to set up a billboard for them.
You may also want to check out the "Pirate Game 3D" demo using this feature.
Perspective camera: A camera with perspective. The opposite is the Orthographic method.
Billboard: A rendering method that always looks in front of the camera, mostly used in effects.
(1) Open the Bake dialog.
(2) Change the Billboard setting in the Setting tab.
- None : Do not use the billboard. Perspective camera is not supported.
- Billboard : Rendered as a billboard.
- Billboard with fixed Up Vector : It is rendered as a billboard and maintains the Up (+ Y) direction of the world coordinate system.
There is no option for Perspective camera.
If the Billboard setting is not None, the Perspective camera is automatically supported, recognizing the way the camera is rendered.
(Orthographic cameras are supported regardless of the billboard option.)
Note
If you use the Billboard method, the camera's "Camera.transparencySortMode" property will be changed to "TransparencySortMode.Orthographic".
To prevent the TransparencySortMode from being forcibly changed, uncheck "Set Sort Mode to Orthographic" in the Bake dialog.
When the billboard setting is turned on, when the game is launched, it will automatically search for "camera to render" and keep looking in that direction.
After recognizing whether the camera is Orthographic or Perspective, the shape is corrected to fit the camera.
Billboard setting: None
It does not look at the camera, it does not render properly in order.
Billboard setting: Billboard
It always looks at the camera.
Even if the camera has a perspective, it will render normally.
When the camera is tilted, it always renders straight.
Billboard setup: Billboard with fixed Up Vector
It always looks at the camera.
Even if the camera has a perspective, it will render normally.
Unlike the Billboard method, the Y direction of the world coordinate system is fixed, so the camera is skewed as much as it is tilted and rendered.
When rendering using the billboard, the character always faces the camera according to the billboard rule, regardless of the rotation of the GameObject.
So it was impossible to rotate the character.
However, based on user reports, we learned that there are cases where the billboard needs to be rotated, so we added a new rotation function.
A "Parent object" is needed to additionally rotate the character that rotates in a billboard method and faces the camera.
Let's learn about two ways to rotate a character by changing the Rotation value of the parent object's Transform.
This is a character placed in 3D space.
The billboard has been activated and is being rendered using a Perspective camera.
If your character is on level ground, the billboard will render naturally.
Now let's place the character on the ramp.
The character should rotate as the ground tilts.
However, when you run the game, no matter how much you rotate the character, the character will stand upright and look at the camera as shown above due to the billboard rules.
Since the billboard controls World Rotation, you cannot rotate the character in the current way.
Let's use the newly added option.
(1) Open the AnyPortrait editor and press the Bake button.
(2) Select the Setting tab.
(3) If the Billboard option is set to Billboard or Billboard with fixed Up Vector, the Parent's Rotation option appears.
The values for this option are as follows:
- Ignore: Ignore the Rotation of the parent object and operates in the conventional billboard manner.
- Pitch Yaw Roll (Local): Rotate the character by considering the Local Rotation of the parent object as Pitch, Yaw, and Roll rotations.
- Sync Up Vector (World): Rotate the character using the Up vector (World) of the parent object.
First, select the "Pitch Yaw Roll (Local)" option and run Bake.
You can also set this option in the Inspector.
(1) After returning to the Unity scene, create a parent GameObject for the AnyPortrait character.
(2) Let's change the Rotation Z value of the parent GameObject appropriately.
(3) When you run the game, you can see that the character is rendered tilted to fit the ramp, even though it is rendered as a billboard.
This option adds the X, Y, Z values of the parent object's Local Rotation to the billboard and makes it rotate Pitch, Yaw, Roll respectively.
So it is different from the general Transform operation, and it rotates as above according to the value.
- X rotation works as Pitch, so the character tilts forward and backward.
- Y rotation works as Yaw, so the character tilts left and right.
- Z rotation works as Roll, so the character spins while looking at the camera.
However, since rendering errors occur in Pitch and Yaw due to the difference in Z position according to the Depth of the character meshes, it is common to only use Roll according to the Z value.
The second method is to rotate the character using the Up vector of the parent object.
It has a different characteristic from the previously explained method in that it can use the World Rotation of the parent object.
(1) Click the Bake button.
(2) Select the Setting tab.
(3) With the Billboard option activated, change the value of Parent's Rotation to Sync Up Vector (World) and run Bake.
Back in the Unity scene, let's rotate the parent GameObject.
We've written a simple script in advance so that we can see the Up vector of the parent GameObject.
Let's rotate the parent GameObject.
If you look at the image above, you can see how this Sync Up Vector method works.
You can see that the character rotates so that the Up vector in the World coordinate system of the parent GameObject is the character's Up vector.
At this time, the character's rotation only works in the Roll method.
Also, in this method, Billboard and Billboard with fixed Up Vector among the Billboard options behave the same.
Caution
If the Up vector is parallel to the camera's Forward vector, the character's rotation will behave abnormally.