- Home /
Sprite clips into 3D environment; any way to render the sprite?
I'm using 2D sprites in a 3D environment, but I'm having problems with the sprites clipping into the 3D walls. I have a script on the sprites that makes them rotate to "face" the camera as it orbits vertically. However, the 3D walls do not rotate, and therefore the sprites will sometimes clip into the walls.
Here's an example of this:
Is there any elegant solution to have the sprites render fully, even if they're clipping through something? Or if not, is there any other solution that can solve this dilemma? I can't just have a separate ortho camera render the sprites because then they wouldn't appear "behind" the walls, either.
Don't use a script. Billboarding should be done in the shader.
You are amazing. Thank you! (Such a "duh" solution, too.)
I just tried using a CG shader ins$$anonymous$$d... but to no avail. The result is exactly the same: the sprite clips through the wall.
this script help you to animate shader
function LateUpdate ()
{
myTransform.LookAt(target);
}
function Awake ()
{
var myTransform = transform; //cache the transform
var target = Camera.main.transform; //cace the transform of the camera
}
Answer by antiReady · Feb 21, 2014 at 10:37 AM
I'm working on something similar (even using the same RO test sprite haha). To fix this, I fixed the sprites Y axis and scaled it (taking camera angle into account) instead of rotating it on all axis.
Here is a crappy drawing to visualize what I mean (side view)
To the camera it looks exactly the same but it solves the clipping problem quite nicely
Hope it helps :)
Your answer
Follow this Question
Related Questions
How do I prevent my 2D Sprite from clipping into my 3D Environment 0 Answers
2D sprites in a 3D environment - undistorted without clipping 0 Answers
Can I use clipping with Unity Sprite in NGUI? 0 Answers
How to change the textureRect of a Sprite with a dynamic way? 0 Answers
Create a Sprite Animation Clip in Code 3 Answers