- Home /
Player face dissapears behind another mesh rendering behind it?
In this demo: http://www.jabberworx.net/cellgame/cellgame.html you can see a character sprite with a red face. If you press the down and right arrow on your keyboard when the game loads up and run it you'll notice the players face will disappear after it reaches a certain point.
The player face is a child of the body and its z position is offset by -0.05f of the body, I've checked and have found in terms of z coordinates it's always in front of the body, yet it still disappears behind the body.
Any ideas why this is happening and how I could fix it? I'd like to keep rendering in perspective view though, I know orthographic rendering would probably fix this.
Can you show us a screenshot of the Scene View while playing in Unity and while the face is placed behind the sprite ? (please select your two objects to see the gizmos)
And is the face a tk2d sprite like the white body ?
And what if you add a little script which will force child's Z-position (absolute or relative to its parent) ?
Answer by Bunny83 · Dec 11, 2011 at 03:47 AM
How do you render your "body" and what is it actually? Also a 2D sprite? Do you use a sprite engine like SpriteManager2 or something like that? If it's a billboard sprite it will always be rotated towards the camera. When you move to the right side from the screen center the body sprite will be tilted. If your face-sprite stays in the moving-plane (even when offset by 0.05) the body will hide the face sprite at a certain angle. If you look in the other direction (move the face sprite to the other side it's visible again)
I'm using tk2d (toolkit 2D) to do the sprites, they're not billboarding or rotating on their own (rotations are frozen).
Are you sure? Billboarding sprites would totally match the effect. Its the same radial around the screen center. Have you checked the rotations of all relevant objects (so the object itself and all of it's parents) when you move close to an edge?
I haven't used toolkit 2D yet so i can't say much about that.
It's not billboarding, like I said, there are no rotations at all besides on the z axis, I also know as a matter of fact the sprites don't billboard from manually moving around the camera in-game.
Answer by solidd_swa · Nov 17, 2012 at 10:55 PM
I am having the same issue with 2D tool kit, did you manage to solve this?
It's a limitation of Unity, apparently it's difficult to render multiple transparent objects so unity doesn't get very granular with the sorting.
You can get past this by rendering using two seperate cameras, one for the body and then the next one would do the face, but this can cause other issues such as the fact you have to render EVERYTHING every time just for the face and body.
Your answer
Follow this Question
Related Questions
Custom Transparency shader occasionally losing transparency? 1 Answer
How to get the depth values of the camera view? 1 Answer
CommandBuffer.SetRenderTarget becomes strange with BuiltinRenderTextureType.Depth 0 Answers
Debug Rendering using the depth buffer 3 Answers
Scene View Camera Depth Texture? 0 Answers