How can I remove the unintended line in Unity generated by tilemap - c#

I downloaded and imported the free tilemap esset but there are vertical lines in the Game screen. The error didn't occur in the Scene screen and even when I had tried building it the game runned without any problem. So, it seems not to be deadly error but it can disturb me while making and testing the game.
I checked the Pixel Per Unit, Filter Mode, and Compression of this tilemap and they were correctly set. I disabled anti-aliasing as well (It worked partially, removing horizontal lines).

While this should resolve the artefact/tearing issue you’re seeing, using a Sprite Atlas is also a good habit to get into even if you’re not seeing the issue anyway.
The Sprite Atlas packs the sprites in such a way that they have a little padding that can stop the texture bleeds that can sometimes cause unwanted horizontal and vertical lines to appear between sprite tiles.
The Sprite Atlas workflow can be read in detail here.
From that documentation, the 3 basic steps are:
Create a Sprite Atlas Asset.
To create the Sprite Atlas Asset, go to Assets > Create > 2D > Sprite Atlas. Unity creates the Sprite Atlas in the Asset folder, with the file extension * .spriteatlas.
Select a list of Objects for Packing into the Sprite Atlas.
The Objects for Packing list displays the currently selected items that are in the Sprite Atlas. You can place Texture2D and Sprite Assets in this list. Drag and drop a folder directly onto the list to automatically add all valid content within the folder to the list (only the folder appears on the list).
Enable Include in build on Sprite Atlases to include them with the project.

Related

Sprites disappear after game is built (unity engine C#) Not an issue of layer they are on

I am currently writing a 2D game in unity and whenever I build the actual game, the sprites all disappear, the player is the only thing that remains.
However, the sprites are still there, just invisible. It's not an issue of order of layer and am having trouble fixing it.
I am using SpriteShapeController.
SpriteShapeController auto shows as it having a sprite so it made me think I had a sprite already
I just made Custom Square Sprites and added them in.

Taking a screenshot from one of the Camera GameObjects when the game is running and then output

I want to make a game in which the player can take a picture of the view in one of the camera GameObjects whilst the game is running and then save that image and view it later in the same play session, much like taking a screenshot using a camera item in other games and then viewing it in a gallery. I was wondering if there was currently anyway of doing this within Unity as it will be a central mechanic in my game.
There are multiple ways to do this.
The simplest is Application.CaptureScreenshot, which will create an image file. To explore the screenshots, use a file explorer package, or implement your own.
The other solution is to use a RenderTexture and to export the data to a List. You can then create an UI to explore the List. The problem is that each texture will be uncompressed and kept in memory, which can become dangerously heavy after only a few screenshots. Only do this if you don't have access to files or if you only keep the last few screenshots.

Unity 2D sprite render sproblem in final built project

I have Unity 2D project. When I play it in unity editor, all is ok. But if I build a project and run it as a file, I have problems with sprites - when a character is moving, triangle parts of sprites are disappearing or getting white. How can I fix it?
I've tried to change different settings in the inspector, like wrap mode or other. Also, I added 1px border to sprites, but it did not work. Do you have some advice?
Here is an image of what I have:
https://imgur.com/a/Ft7HahL

How to always get the AR design in front of the spatial walls Unity HoloLens

I am building an app for the HoloLens gen 1 device using Unity 2018.3.13f and MRTK V2 RC1. I got a simple AR design with 2 text objects and 1 rawimage object. After building the project and deploying it to the HoloLens the AR objects ends up behind the spatial mesh (you know all those spatial triangles), but I want all the objects to be in front of the wall.
How do I accomplish this?
The canvas is set to be on the main camera
I have the original settings for the DefaultMixedRealityconfiguraitonProfile if there is something there that needs to be changed.
This is how it looks through the hololens with the app when it does not show the mesh of the wall (sorry for the bad quality)
and this is how it looks when it falls behind the mesh
Do I need to add some mesh renderer or something on the MainCamera to make this possible?
Any help is appreciated, thanks!
I don't believe that the MRTKv2 as of 2019/5/9 has code that will auto-ensure that a specific object is positioned in between the camera and other arbitrary meshes and colliders (i.e. the spatial awareness is one such mesh, though you could imagine just having an arbitrary box or plane in the scene that would occlude that object, in which case, maybe you'd want your "in between" object to stay in between both those two types of potentially occluding things).
There used to be a script in the HTK called Tagalong.cs that would do something like this by doing raycasts from the camera to collidable object:
https://github.com/microsoft/MixedRealityToolkit-Unity/blob/htk_release/Assets/HoloToolkit/Utilities/Scripts/Tagalong.cs
This single large script I think got broken up into smaller scripts (i.e. specific behaviors in the solvers here:)
https://github.com/microsoft/MixedRealityToolkit-Unity/tree/mrtk_release/Assets/MixedRealityToolkit.SDK/Features/Utilities/Solvers
However, from what I can tell, the specific interaction of "keep things automatically between the camera and whatever collidable object" wasn't preserved. Someone else can correct me here if I'm wrong, it looks like this wasn't a behavior that got preserved in V2.
Going forward, there are a couple of possibilities:
1) Probably file an issue on Github here (https://github.com/microsoft/MixedRealityToolkit-Unity/issues) to request this feature be ported over.
2) Use the code in Tagalong.cs to add your own solver that would accomplish this (i.e. the code looks to be all there, there's just some work needed to get done to reorder it to handle what you want)
If you use a sprite renderer, set order in layer (into 0 or -1).
If you use a mesh renderer, try to deactivate dynamic occluded.
Try to change the hierarchy of the sorting layers under Edit-> Project Settings -> Sorting Layers

Animating a sprite

Im developing a game like "bubble-bobble". So far I have done physics and collision detection.
Now I want to make my Hero (Rectangle Sprite) animated. I would be glad if someone could explain simple scripting for simple animated characters or some nice links for animation.
The XNA Documentation includes an entire article on Animating a Sprite. The basic technique is to use an AnimatedTexture class, which is included within the Animated sprite sample code.
The high level idea is that you load a texture into memory using a graphics API. Since you're using C#, this is most likely done through XNA.
This texture you have loaded contains each frame of animation that is required, and may span across multiple textures. When you go and render your 'sprite' object, you pass the XNA API the texture you want to use, and a source rectangle coordinates that surround the specific frame of animation you want within that texture.
It's up to you to manage this process. I create tools that assemble these source rectangles and stores meta data about each specific animation each sprite has; like which rectangles, and the duration of each frame, etc.

Categories