I've been trying to fix this for quite some time now. All the solutions I find seem to be for sprite sheets. I am using tiles I downloaded from the asset store. They are not sliced up by unity but rather single pngs already separated in the asset folder.
When I combine them to platforms I sometimes get lines between the tiles where the background shows through. These lines are only visible while moving over the tiles.
I couldn't manage to screenshot it as of yet.
I have tried creating a material with Pixel snap on and assign it to my prefab but that didn't work. Even assigning the material to all the pieces of the prefab didn't work. The lines usually only show in between prefabs anyway.
Thank you very much!
Related
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
I know I can use sprite packer to pack sprites so that there will be only one drawCall. If I slice a sprite sheet into multiple sprites, will it have the same effect? I experimented on my own, but there is no batching saved and I am afraid I did something wrong?
I used UI Image. And I used same material on them to hope batch them.
You may open the Frame Debugger to inspect whether your sprites are batched.
See also DrawCallBatching for more details on when and how draw-calls will be batched.
I want to create a 2d game with tiles that are interactable, i.e farmland, trees, breakable rocks, etc.
Now if I create my tilemap in Tiled which I have done so far, it does not offer that type of control.
I found some posts on how to deal with this but they are at least 3 years old, so wondering if there is some updated answer? maybe something built in to Unity or a plugin I'm not aware of to help create Tilemaps inside Unity?
I want, for example, 1 tile of grass to be able to react if I hit it with a hoe, or water, and change to dirt. Is my only option to create prefabs and place every tile as its own gameobject? won't that kill performance in a large world?
You could try exporting your Tiled tilemap to .tmx format, creating a script in Unity that loads .tmx files for your map and reads every single tile in a for loop.
You would need to assign a prefab to each tile ID of your tilemap, and in that prefab you could have your script with logic attached (grass reacting to a hoe/water) and graphics.
Other idea is to export one big image of your map, and then export .tmx format in the same way as explained before but create game objects only for ID's that player can interact with and only attach scripts to them.
In my resources folder structure I have myself a file, now in the unity editor this file is a Texture Type Sprite (2D and UI), now when I attempt to run this code in one of my scripts
var icons = Resources.LoadAll<Sprite>("Images/BuffIcons");
My icons variable is empty, now if I change the line above to
var icons = Resources.LoadAll("Images/BuffIcons");
It comes back with an array which has a Texture2D and then multiple Sprite objects. Now why can't I cast the objects to a Sprite?
Also just for your information the Sprite (2D and UI) is a Multiple sprite so this sprite in total has like 42 different sprites. It seems to me the sprite which holds all the other sprites is classed as a Texture2D and then all the sprites inside of the Texture2D are Sprites. How can I just tell the Resources.LoadAll to load the sprites?
So this is a really silly answer however I'm not going to delete this question because around the web I have seen this question in a view places and all the answer's didn't work for me so. Here is my fix :D
Basically I have a Sprite (2D and UI) file in Assets/Resources/Images/BuffIcons, in my code I have this line
BuffIconSprites = Resources.LoadAll<Sprite>("Images/BuffIcons");
Basically all I had to do was simply close Unity and re-open it, it seems if you create the sprite asset which contains multiple sprites you need to close and reopen Unity, I think this is something to do with the solution file which is constantly updated when stuff changing in your Unity file.
P.S. as you can see the line of code I provided hasn't changed. So I'm 100% sure this problem is something to do with the Unity solution
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 :)