Unexpected sprite tearing? - unity3d

I making a 2d game and I am having some very random problems... My sprites are not displaying as they should be. Below is a screen shot of what I see when I run my game. This bug is present in the game window and the scene window, both when the game is running and not running. And the glitch is not because of the tiles being offset (The background is made up of tiles), if you look closely the player sprite is also glitched up. I have tried restarting unity and my computer, one of which has worked. I have been having this problem ever since i started using tilesets (using one PNG image and cropping out smaller sprites by setting the sprite mode to multiple, instad of using just one PNG image where there is only one sprite and the sprite mode is singular). How do I fix this? (BTW I am using Oryx's lo-fi fantasy and sci-fi sprites at www.oryxdesignlab.com)

This happend when your atlas is not sliced correctly. When you making 2D game there are several important things about sprites.
Set Filter Mode to Point
Set Fromat to 16 bit or TrueColor (in special cases)
Make sure that your atlas is sliced properly.
Edit:
Adjust "Max Size" - make sure is value represents number equal or bigger than spritesheet size
The best way in sliceing atlas in Sprite Editor is NOT to use automatic. I got glithes like that in my project too and those steps can eliminate them.

Have a look at your Sprite in the Sprite Editor. I think you can get to it by double clicking.
Your sprites will have sort of boxes around them to identify each individual sprite (if you set your texture to multiple). One of these boxes will not have sliced correctly, and will have overlapped into another sprite, hence why you're seeing what looks like the arm of another sprite in your picture :)

Related

Sprite dislplays all of the frames without acting like an actual sprite

So, i've been trying to make a videogame on unity, and i made my first sprite on piskel. Exported it as PNG but can't seem to make it work on Unity. I imported it as a new sprite and even selected sprite (2D and user UI) on the menu.I selected 2D sprite but it doesn't work. It's just like if I put an image there, and not a sprite.It stays still I even tried using another sprite format More rows
I can't find anyone else with the same problem out there on the internet, so help would be much appreciated. Thank you.
Selecting 2D sprite isn't the full story. You will also need to make the sprite "multiple" instead of "single" and split it up in the editor (now available in the package manager).
That will split it up into frames for you, then you drag and drop a single frame.
https://docs.unity3d.com/Manual/SpriteEditor.html

No "Pixel Snap" option in 'Sprite-Lit-Default' material causing some sprites to tear

The Problem:
I have a pixel-art based project that uses tilemaps and etc. Previously with just the default material Sprites/Default, I have this "Pixel Snap" option:
However, ever since I upgraded to LWRP/URP; and used 2D Lights (my game has a day/night cycle); all of the sprites have to be upgraded to a new Sprite-Lit-Default material which allows my sprites to be affected by the 2D Lights. The only problem I noticed in this new material is that it hasn't got any "Pixel Snap" option:
And after I used this new material, I notice some of my sprites (specifically the ones on the Tilemaps) tear. It's not game breaking and it occurs sometimes, but it's really quite annoying (and let's face it, it looks bad for your game to have that bug).
I haven't noticed this tearing bug on my other sprites (player, trees, obstacles, etc) only particularly on the tilemaps.
What I've Done So Far:
My sprites are set to Point (no filter), and Compression is set to None. On my tile sprites, there are no transparent edges etc. Even if I use Unity's Pixel Perfect Camera, the problem is still there.
Duplicated my tilemaps and offset the other ones to -0.01 or -0.02 on its X axis (so just in case it would tear, the player would still see the same tilemap).
None of these things have fixed the problem so far.
Are there any ways to bypass/fix this issue?
Thanks a lot!
What Solved My Problem
I placed the tilemap sprites on a sprite atlas, set the filter to Point, set the compression to None, left everything else by default, and then clicked "Pack Preview".

How can I use baked lighting on sprites? / How to light up a large area in 2D?

I'm having trouble figuring out how to light up large area(s) of sprites in Unity 2D. My previous knowledge on Unity's lighting is zero.
I first tried using a large amount of point lights and using the "Sprites/Diffuse" material, but about only five would actually render at a time, so I guess there's a limit on that.
Then I tried putting in an area light. That didn't do anything, so that's when I started doing research about baked lighting on sprites (and baked lighting in general). I found stuff like this but I couldn't get it to work either because it's outdated or because I don't know what I'm doing. Other answers I've come across seem to assume that the reader knows anything about lighting in Unity in the first place which, to be honest, I don't. Unity's documentation website had some information on it, but no tutorials that go into how to set up baked lighting.
I've tried a bunch of different combinations of materials (like using the "Standard" shader for the sprites instead of "Sprites/Diffuse", emission, ect.) and I enabled "Baked Global Illumination" in Lighting>Settings.
If baked lighting isn't possible on sprites (or isn't worth the trouble), what are the alternatives?
Edit: I made sure not to have the lights pointing the wrong direction, and I do realise that Unity2D is just like painting onto a piece of paper in Unity3D. I was able to get point lights to work, but only a few at a time. I don't need to do the entire screen at once, I need to do a large specific area at once.
some tips...
working with sprites your in 2d... when you add a light, switch to 3d mode, and rotate to make sure your light is pointed at your objects, and oriented so as not to be on the same plane, or level with them, as this will cast all the light behind them.
if your trying to light up everything on the screen(in camera) attach an area light to the camera at the cameras position, point it where the camera points, and then in the inspector on the right, you can change its variables. intensity, range, width, height etc.
Emissive Texture:
https://www.youtube.com/watch?v=oa6kW5HhRd4
For some reason, I never even thought about going into the asset store. I found this for free, and it looks like it will work: Light2D.

Sprites quality is very bad in Game window in Unity

I have created a 2D project. The images I used for sprites are all with high resolution. However I do not know what settings I have changed today, the sprites in game window started look terrible when I tested the game(good quality in scene window). And this happens to all of the projects I created earlier. But when I build the exe file to play, the graphics look all good with original quality. Could anyone tell me how to fix this issue?
Scale back the game view to 1x and change the size of your camera instead or set your sprites to their original size if they have been resized
If you have a Retina screen, make sure you uncheck the following checkbox.
Watch this screencast
For 2D game also make sure Projection property in Camera component is set to Orthographic

Purpose of mipmaps for 2D sprites?

In current Unity,
For use in Unity.UI as conventional UI ..
for any "Sprite (2D and UI)", in fact it always defaults to having "Generate Mip Maps" turned ON. Every time you drop an image in, you have to turn that "off" and apply.
As noted in the comments, these days you can actually use world space UI canvasses, and indeed advanced users may indeed have (say) "buttons that float over the head of Zelda and they are in the far distance". However if you're a everyday Unity user adding a button, just turn it off :)
In Unity, "sprites" can still be positioned in 3D space. For example, on a world space canvas. Furthermore, mipmaps are used when the sprite is scaled. This is because the mipmap sampling is determined by the texel size rather than the distance.
If a sprite is flat and perfectly scaled then there is no reason to use mipmaps. This would likely apply to your icon example.
I suspect that it is enabled by default for 2D games where sprites will often not be perfectly scaled. To clarify, a sprite does not need to be on a canvas. Sprites can exist as their own GameObject with a Sprite Renderer (not on a canvas.) When this is the case, scaling the camera view will change the sprite's size on the screen resulting in mipmapping due to the texel size changing. This results in making the sprite always perfectly scaled challenging without a canvas.