Is there a good way to have 2D sprite in 3D world?

For example, a complex structure 2d character with several sprites for his body, in a normal 3D world. You know. sometime it’s easy to get a problem that some part of his body get into wall or floor, especially when it’s a multi-part sprite character

Thats basically what Unity 2D projects do already. Maybe you can clarify your issue?

Are you talking about something like Paper Mario?

Yes. Textured quads that face the camera. Culling layers keep him in front of the geometry if you don’t want his body parts clipped in walls.

yeah i know but it limits that the character cannot get behind a 3D object

No. Unity 2D projects are about 2D sprite in 2D world. The z position is just for sorting

yes something like that

:confused:

What you’re trying to do is use a 2d sprite that behaves BETTER than a 3d graphic… as 3D graphics are also subject to clipping. Let me ask you… how should that work?

There is no “2D world.” It’s just an orthographic camera aimed perpendicular to the xy plane. That’s it. That is all that 2D in Unity is. Okay there’s the physics2D which assumes xy are the two dimensions, but after that it’s all in 3D.

When rendering 3D objects, it use depth test so the sorting doesn’t matter for solid material. When rendering 2D objects, it only depends on the sorting.

I have billboarding script that I’m using for 3D hologram-like ui in my game (canvases), partially from the Unity wiki, I could post it there if you want. Would require modifying it so it won’t rotate sprite on the X axis tho, or it will look weird when camera tilts down.

Most likely you’d also have to use regular quad with textures, but animated texture scripts are a thing.

now THAT cause the problem. It seems Unity do the “standard depth-based sorting” with just the 3D distance between SpriteRender and Camera. If i want to have a 2D character with separated limbs, the sorting will be influenced when moving around, because of the distance between SpriteRender and Camera. Of course I can set the z in different value to help the sorting, but then it may get some displacement when moving around, because of perspective.

I got a way to fix the problem, which is using a script to control the sorting layer value of all SpriteRenders every frame, based on the position of the parent object and the inner sorting. But I don’t feel it’s a good idea

Yes. Ever heard of a game called doom? It was built of 2D sprites in a 3D world.

Two methods come to mind. Billboards, where you basically make a sprite that always faces the camera, and change the sprite based on the rotation of the object in ‘3D’

Shaders where you make a 3D model look like it’s 2D.