# Top down 2d orthogonal view with 3D elements (Unity)

I've decided to give Unity a go with my project. I want to create a 2d RPG perspective world, but with elements of 3D mixed in. So for instance, I think I might make trees and grass 3D, for this to work, the grass would have to realistically blend with the character (a 2d sprite) as they walk through it. To be clear, I'm thinking of grass like you would see in a fully 3D game (like this).

As I understand it, the sprite objects (characters and whatnot) would need to maintain their rotation values whatever the rotation of the camera is. I don't plan on rotating the camera, the game would appear like a 2d game (2.5d is perhaps a more appropriate term) but in order to achieve the effect I want they would not be allowed to rotate in the camera's view.

I'm very new to Unity so I'm not quite sure where to start. I should also note I don't plan on making everything 3d, just particular objects like the ones mentioned.

Edit 06.05.16:

I'm not sure why I can't find anybody else with this problem solving it the way I am. Here's a diagram of what I've implemented and it seems to work well:

The camera's Y axis is set to 45 degrees. I'm not sure why but the number 1.418 works as the scaleY value for the camera's projection matrix. for making both sides appear as equally proportioned squares.

I don't see any distortion of textures, shadowing looks ok, the whole distorited 2d rpg perspective feels just right.

I'm a bit confused as I've seen some overly complex suggestions and solutions to this problem on google, but this seems to me to be the simplest and most appropriate solution, and I've not found anyone suggest it. Everything appears in proportion. I assume I'm not aware of an important flaw in the solution because otherwise it would seem absurd other people wouldn't arrive at the same solution.

Regarding billboaridng - billboarding 3D movable sprites doesn't work well in 3d environments IMO, as they often will be tilted at a 45 degree angle and risk intersecting 3d objects:

Particularly tall sprites would be very problematic, unless the scenery was also tilted, like this screenshot from a Zelda game demonstrates:

• 1.418 works as y scale factor because it's quite close to 1.0f / sin(camera_angle). An even better approximation would be 1.41421356237. – Philipp May 6 '16 at 13:12
• "I've not found anyone suggest it" Huh? Scroll down, Philipp suggested this type of solution to you two days ago: "Another option is to always keep the sprites perpendicular to the 2d ground-plane. This makes their sorting behavior more intuitive, but shortens them perspectively, so they will be vertically shortened and won't look exactly like they look in your image editor. But you can compensate for that by scaling them on the y-axis according to the camera angle." (Here scaling just the sprites to keep foreshortening of the 3D elements, in case that was desired) – DMGregory May 6 '16 at 13:50
• In any case, if you want to share a solution you should post it as an answer, not as an edit to the question — this will make it easier for other visitors to understand the problem & solutions offered. – DMGregory May 6 '16 at 13:53
• The original version of Phillipp's post read differently and I didn't see the edited version until now. I think my post reads quite straight-forwardly so I'll keep it as it is. Thanks for clarifying the y scale factor number, Phillipp. – hedgehog90 May 6 '16 at 14:31

When you have 2d sprites in a 3d environment, they work like two-dimensional planes. Think of them as cardboard-cutouts which are moving through the world.

When you want to rotate these cardboard cutouts to always face the camera, then the search term you are looking for is "Billboarding". It can be implemented by attaching this MonoBehaviour to it:

using UnityEngine;

public class Billboarding : MonoBehaviour
{
void Update()
{
transform.LookAt(
transform.position + Camera.main.transform.rotation * Vector3.forward,
Camera.main.transform.rotation * Vector3.up
);
}
}


However, when you aren't going to rotate the camera anyway, then you won't need this script. The camera in a Unity game won't rotate or move unless you have a script which tells it to.

Just rotate your sprites into the direction of the camera in the editor and then keep them that way. Another option is to always keep the sprites perpendicular to the 2d ground-plane. This makes their sorting behavior more intuitive, but shortens them perspectively, so they will be vertically shortened and won't look exactly like they look in your image editor. But you can compensate for that by scaling them on the y-axis according to the camera angle.

• I'd like your opinion on my suggested solution in the edited OP – hedgehog90 May 6 '16 at 12:21
• @hedgehog90 Isn't it exactly what I suggested? – Philipp May 6 '16 at 12:44
• Oh, so you did! I only saw the original post before you edited it where you adding the final line. – hedgehog90 May 6 '16 at 14:24