How to handle a jank (non-uniform) spritesheet in Unity 2D - unity3d

I'm trying to rip the among us textures into Unity, but I'm having trouble with the spritesheet for crewmate animations like walking, venting, idle, etc.
Here's the spritesheet I'm talking about: https://github.com/Overload02/among-us-assets/blob/main/Players/Player-sharedassets0.assets-55.png
You can see it is not consistent at all, making a uniform square or rectangle cut impossible.
What I tried originally is just creating all the boxes manually, but this looks terrible.
How does one handle this elagently?

Maybe you could use each sprite as a seperate image instead of a spritesheet. then you could edit the edges of each one seperately.

Related

Unity How Do I get these blocks

I want to use these cubes in my own game but I have literally no idea how he got them. Look at the cubes with the black outline, the walls the ground the roof, how do I get a cube with the outline like that. I know this is a stupid question but I have tried but I cant find out why.
Thanks in advance!
Those are not individual cubes.
Take as example one of the walls, probably it's a single cube (rectangular prism) for each wall, the trick is that it has a material with a texture applied to it and a normal map.
In simple words:
A texture is an image containing the colors the object has. In this case the blue color of the walls and the black lines simulating cubes.
A normal map is something like an image but it contains information about the "depth" of each pixel in the image. In this case it indicates that the black lines should be "deeper" than the rest of the image.
A material is the object that combines the texture with the normal map and along with other settings can tell the computer how exactly it should look like.
Of course this is only a very brief definition, if you want to know more about it I recommend you to read about: Materials, textures and shaders in Unity. There are some tutorials in Unity web page.
Use photoshop to create a single tile of each type of block and use it.

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.

OpenGL lines in Unity, draw once but show forever?

Right now in my unity project I am drawing OpenGL lines similar to the way drawRay() works in Unity. I have been trying to make it so that once the lines are rendered/drawn they stop redrawing themselves so that I can save on performance.
Is there a way to only draw an OpenGL line once in the OnPostRender() function but have it continually stay drawn in the unity scene as if it were a static image now?
You can't do this
If you want things to persist, then they need to be drawn. You can't have your cake (visible polygons) and eat it too (not draw them).
The only way to save on performance is to batch things together into larger blocks of drawable polygons and draw them all at once in one go.

Creating cleaning effect in unity3d

I'm trying to build some simple game(learning) where you will have to clean objects.
That means for example you have a monitor with dust on it so you can't see the image. You then uses mouse or finger to move arround monitor to make image visible.
So what I've got so far is 2 images first being the monitor image and second being the dust before it. I've managed to realize when user swipped all image down. But what would I like to do is when user tap the screen somewhere only in that radius r the front image disappears.
I'm guessing I should be using layer mask, but I have no idea how to do it.
I basicly managed to write my own shader that only shows layer with correct image but no idea how to do that you can accualy get some cool effect from it.
Any ideas will be apriciated!
I would use render texture for this. It allows you to use image files as a brush. And it's quite fast. The idea is to use render texture as a mask. You start with black texture. Whenever player touches the screen you render your brush image to this texture. But this feature (render textures) is available only in Unity Pro.
You can still use texture as a mask if you don't want to buy Unity Pro. But this will be definitely slower than render textures. How much slower I don't know. The options are:
Create ordinary texture (Texture2D) and use SetPixel or SetPixels to update mask when player touches the screen. If you want to go this way, I would recommend to use much smaller texture than the screen size (4x, 8x depends on the quality you want to get). Otherwise it will be damn slow.
Create ordinary texture (Texture2D) and use ReadPixels. This works pretty much the same way as render textures but it's slower. This technique is explained here.
Using render texture (requires Unity Pro)
Ok. I've made an example: https://drive.google.com/folderview?id=0B60e_iFEZd1-RlB4LVN6NE84clU&usp=sharing
There are:
Image that player needs to clear from dust: Image.jpg
Image of dust that we draw on top of it: Dust.png
Image that we use as an erasing brush: Brush.png
Our render texture that we use as mask for dust: Mask.renderTexture
Shader that we use to update the mask: MaskConstruction.shader
Shader that we use to render dust (it combines Dust.png and render texture): Masked.shader
Script that brings everything to life: MaskCamera.cs
Main scene: Main.unity
I think this might be helpful. The Main objective of this Code sample is to create a dust/fog removing effect using Unity. Using, Texture Masking shader, Mask Construction Shader, Render Texture, Camera Masking Script and masking camera, you can create your own effect. Read on to know how and download the source code. It’s free!!
http://studio.openxcell.com/remove-dustfog-object-unity-swipe.html

Breaking up a sprite in cocos2d

I'm making a 2D plane fighting game for the iPhone in cocos2d. I'm trying to make it so when you shoot an enemy plane, it breaks into a couple of separated pieces that will fall out of sight. What is generally the best practice for breaking one sprite up into many? should I create new images for each separate piece, or treat the initial image like a sprite sheet, and make a new sprite from segments?
Please look at this tutorial
It makes a grid of points then moves the internal (not-edge) ones around randomly a bit so it's not all perfect triangles. Then each update it moves/rotates the triangles separately--then draws them all at once.
You treat the whole thing as a sprite, so can run any of the usual actions on it. This example uses CCMoveBy to move the whole group down off the bottom.