#๐ผ๏ธโ2d-tools
1 messages ยท Page 5 of 1
The flipbook works by manipulating the UVs.
ok, that make sense
Generally, you edit either the texture or the mesh to have the UV borders have a bit of space to avoid bleeding
ok, which do you reckon would be easier/better, editing the mesh or the texture?
This is assuming you followed the earlier advice from Fogsight?
And changed the texture settings?
I have no clue, i hope so though
Since they are just squares, I'd edit the shader to shrink the area of texture it is capturing a little
ok, and how would i do that, im not the best with shadergraph sorry lol
ok cool!
Basically, pixels are interpolated so anything RIGHT on the border will have leakage.
sometimes left though aswell, it depends on the mesh, and the order of the sprite atlas
assuming i mathed correctly, this should now work according to this forum post? I shall try this and report back!
hmm, nope not working, weird
oh it does
ish
1e-05 scale gets rid of the leakage
but causes this...
going below -1, or above 1, has unusual consequences
You really should need only the tiniest offset
sadly that seems not to be the case, unless I messed up the shader, which i probably did lol
aha i did mess it up, this has fixed it, and has also entirely solved my issue!
(now how do i mark a forum post as solved?)
In the tile palette editor can I add components somehow to tiles? So certain tiles would always have some component?
(I have a component that controls graphical effects for example)
U will have to learn scriptable tiles
Or use gameobject brush for a quick and easy solution
honestly I'd just delete the post
damn asperite is a dream, but pixel animation is still pain and suffering
Editing in or replying the solution is always good
Leaves a track for people who eventually may search on google for a similar solution
Even if a problem would feel dumb in retrospect, it may turn out to be a repeating stumbling block for different people
ok, yup that is what i did!
@radiant granite You should be able to pick a tile in "local" coordinates by adding the tilemap's world position to the chosen tile position
...If my vector math checks out
It's a prefab at 0,0
Could even have a specific Transform in the prefab denoted as the local origin, if you can't rely on the prefab origin for whatever reason or wish to move it easily
That is 0,0 apparently
I just want to have a standard layout for my tilemaps so I can generate maps with any one of them so I want to be able to access everything by it's index
I do tilemap.GetTile(new Vector3Int(0, 0, 0)); and I get that tile whihc I circled
I see absolutely no logical reason for it giving me that tile for 0,0
It's the world position of the prefab's Transform component
I see, so if I want to think about this in terms of the index inside the tilemap[ independent of the world coords I need to subtract(?) the transofrm coords of the tilemap
but then agian the transofrm is 0,0,0
That depends where in the scene the prefab is
You only need to add the offset position if it's not at the origin
Okay I will just slap a breakpoint in and checkk the numbers
(though the docs don't actually say if Tilemap.GetTile uses world coordinates or Tilemap's coordinates, I assume it's world)
I feel like the docs arent too clear on what is going on with tilemaps
But now, armed with a breakpoint, everything is at 0,0,0 I have no idea where it would go wrong
If you want tile at (1, 2) but the tilemap prefab is at (100, 100), then your tile should be got from (101, 102) which is the same as (1, 2) + (tilemap.transform.position)
Allegedly the tilemap system is a bit of a tech demo, like the 2D lighting
Ah
tilemap.transform.position is 0,0,0 as I expect sadly
Oh well it's okay I will goof around with it, dont want to bother you too much
I'm not totally sure what the problem is, but I hope this clarified at least a little
The positions are always coordinates, but you can treat them as indices pretty easily as 1 tile = 1 unit
add (.5, .5) to get to the center of the tile, just in case it's an issue of trying to sample intersections of 4 tiles
Hey yall, its me again xD. So, I set up two BG images to be parallaxed in my game, but when I press play and move my character around (I'm using cinemachine for the camera to follow my player), my backgrounds are static, they do not move at all. its like their position is locked or something
To be able to replicate them I set their draw mode to be tiled, Tile mode to continuous and I changed the mesh type to be full rect and the wrap mode to be repeat. Anyone have any idea why this is happening?
How are the background sprites meant to move?
So, for the parallax effect I need them to move to the opposite side that the camera is moving right? and the script lets me control the speed at which that happens.
`` using UnityEngine;
public class Parallax : MonoBehaviour
{
public GameObject[] Backgrounds;
public float[] ParallaxSpeeds;
public Camera Camera;
public float Smoothness = 1f;
private Vector3 _lastCameraPosition;
private SpriteRenderer[] _backgroundSpriteRenderers;
void Start()
{
_backgroundSpriteRenderers = new SpriteRenderer[Backgrounds.Length];
for (int i = 0; i < Backgrounds.Length; i++)
{
_backgroundSpriteRenderers[i] = Backgrounds[i].GetComponent<SpriteRenderer>();
}
_lastCameraPosition = Camera.transform.position;
}
void LateUpdate()
{
float deltaX = (_lastCameraPosition.x - Camera.transform.position.x) * Smoothness;
for (int i = 0; i < Backgrounds.Length; i++)
{
float backgroundTargetX = Backgrounds[i].transform.position.x + deltaX * ParallaxSpeeds[i];
Vector3 backgroundTargetPosition = new Vector3(backgroundTargetX, Backgrounds[i].transform.position.y, Backgrounds[i].transform.position.z);
Backgrounds[i].transform.position = Vector3.Lerp(Backgrounds[i].transform.position, backgroundTargetPosition, Time.deltaTime * Smoothness);
float leftBound = Camera.transform.position.x - Camera.orthographicSize * Camera.aspect - _backgroundSpriteRenderers[i].bounds.size.x / 2f;
float rightBound = Camera.transform.position.x + Camera.orthographicSize * Camera.aspect + _backgroundSpriteRenderers[i].bounds.size.x / 2f;
float spriteWidth = _backgroundSpriteRenderers[i].bounds.size.x;
if (Backgrounds[i].transform.position.x < leftBound)
{
Backgrounds[i].transform.position = new Vector3(rightBound + spriteWidth / 2f, Backgrounds[i].transform.position.y, Backgrounds[i].transform.position.z);
}
else if (Backgrounds[i].transform.position.x > rightBound)
{
``
``Backgrounds[i].transform.position = new Vector3(leftBound - spriteWidth / 2f, Backgrounds[i].transform.position.y, Backgrounds[i].transform.position.z);
}
}
_lastCameraPosition = Camera.transform.position;
}
}``
Your camera is not moving, likely because Cinemachine is not used correctly
The CinemachineBrain component should be on the main camera for virtual cameras to be able to move it
oooh ok.
And should I be using the 2D camera?
or just virtual camera?
Yaay. Now it works! ๐ ๐. nice
They are mostly the same thing, except 2D vcam by default has no aim properties and a transposer more suited for sidescrollers
But now I can't change the camera size, lmao it won't let me, its a little too big.
๐ Oooh, i see.
Because your camera is being controlled by CM vcams
I like Cinemachine but it's a whole suite of tools, I don't really recommend it unless you're ready to study the documentation of how and why it works in detail
https://docs.unity3d.com/Packages/com.unity.cinemachine@latest/index.html The first 7 chapters are pretty important to not accidentally misuse the system
It's likely better to go with Pinballkitty's camera script and not worry about all that for now
Sweet, ty. I'll take a read whenever I can.
I am going insane, it cant be world coordintaes since GetTile takes specifically int-s, and if I change the transform of the tilemap/grid/prefab I get the same tiles back
But it's just not indexed right
Actually yeah, it looks to be Vector3int
Which means it can't be floats or world positions like I've been assuming the whole time
I think I've found something tho
The indexing does not run from 0, but after that it makes sense and I can get the cellBounds of the tilemap which is the lower left corner
And from there I can iterate the whole thing just fine
But it's no 0,0 but I need not care since I can get the start point
Oh hell yes, I can get the "bound" and just work with offsets from there
What's the benefit of cellBounds in this case?
Well because the indexes dont start form 0
So I get the bounds and I can tream them "as 0"
var cellBounds = tilemap.cellBounds;
var x = cellBounds.x;
var y = cellBounds.y;
return tilemap.GetTile(new Vector3Int(x+1, y+1, 0));
I see!
This will get what I as a human would think is at "1,1"
That is useful ^^
Glad we figured it out, thanks
why i cant see this obstacle?
its visible only when it not at ground
(im not good at english sorry)
OK I'm getting slightly ticked off now by Unity's tilemap system. I've created a sprite with all my tiles, but as soon as I move tiles in the source file or delete tiles the entire tile palette just becomes broken, because the tiles aren't in the same place anymore. So any painted tiles in my levels becomes another tile or just displays a red color for a broken tile... How are you supposed to change things if all your levels break if you make any changes to tilemap sprites? ๐
Did you change the sorting layer for your obstacle tilemap to be higher than ground?
When you slice the tile atlas up do you use the safe mode of saving tiles? Iโm new so not 100% thatโll fix it but I havenโt bumped into that issue
Last time now I only exported the sprite again which overrode it in Unity instantly, so didn't have the chance to slice it. But previously I've used 'Smart' I believe, which isn't very smart at all. But if I were to use 'Safe' instead it doesn't really help if it breaks before I even get to that point...
Does your sprite sheet resolution change?
@modest cargo Ah, ye it does actually. I think I trim it on export.. ๐ถ
So I assume these are the rules for working with sprites?
- Don't trim sprite on export
- Only replace tiles at specific locations if you want them replaced in the game with a new variant
- Use 'Safe' slice mode
- If expanding the sprite with more stuff, grow the canvas size in right and down directions
Anything else I should know about?
That's about all I can think of
If the sprite slices in .meta file are always lost on resolution change it's better to start with plenty of empty canvas to begin with
I would also give each tile a 1px padding of the border pixel color (or later compile them into a sprite atlas which can be used to add padding also)
Not strictly necessary but sampling errors of adjacent pixels are super easy to run into
Alright thanks. This has been driving me insane. Will read up on the padding thingy.
Hey does anyone know what 3rd party tools are popular for editing tile sets? Is the built in unity one good enough to make simple side scrolling games?
yes, or you can use Tiled I think
When starting a 2d game, are all gameobject living inside a canvas or each gameobject has its main parents as a canvas?
No
Canvas is just for UI like buttons, text and images
Sprites are not images so they don't belong in the canvas hierarchy
Hmmm I see
I wanna make a card prefab for a card game but that has to use sprites and such, but that has then to live inside a canvas to be visible
So it is a bit confusing
What do you mean "has to"
Images components can refer to sprite assets
But you won't get them as sprite renderers
So I should be making my prefab card with sprite renderers and not images? I'm a bit confused on how it work ๐
Sprite renderers and canvases are different things for different purposes
It's best to read about what they do and how they should be used
I think I'm doing it with just empty game objects adding sprite renderer on kt
Yeah reading it right now
You surely can do a card game using either but it's important to know about the limitations
I've seen some tutorials but it's confusing
One goes full canvases the other full sprite render without reasoning on it
But maybe since I'll have to work with texts, canvases could fit
Help pls
https://docs.unity3d.com/Manual/2DSorting.html There's many systems of 2D sorting used by Unity, and just by looking at your screenshot it's impossible to say what's wrong
i cant see any object after tilemap
any object with sprite ready
Hello guys can someone give me a hand I'm going crazy
I am doing this chess in 2d the problem is that it only works in the simulator when I create the build these are not shown neither in android nor in pc
It's like they don't load the prefabs, sprites, colors, etc.
The first 2 captures are the scenes in unity
When I build the build they should look like the other 2 screenshots
But in the created game they look like the first 2, it does not load anything that it creates
If anyone can give me some advice, I would really appreciate it.
You want to make a mobile game?
Hey there everyone; recently on the development of my company project I noticed that there is very little documentation sourrounding setting up a Portrait Camera for mobile devices inside of Unity.
This tutorial explains the workflow and covers various Unity settings throughout the editor.
If this tutorial helped you out please leave a like and...
Does anyone know how to put an image on top of another image ? Iโm trying to put the character on top of the image of the maze, but when I do so the character goes behind the maze image and gets hidden
Ui elements are sorted top to bottom.
You probably do not want to use a Canvas or Image components for gameplay elements like players or levels
Canvas is practically suited only for UI elements
I would seek out tutorials that teach making 2D games out of sprite renderers
how do i solve the weird borders ?
They seem to be sampling errors from adjacent tiles on the sprite sheet
The most effective way is to add 1 pixel of padding to each sprite so the adjacent pixel is their own color, not the neighbor's
Generating a sprite atlas has the option to add padding automatically
how do i do this ?
Which one?
adding padding
If you're working in a pixelated style make sure texture filtering is set to Point and that mip maps are disabled
Also consider pixel perfect camera workflow
ok thanks !
You'd edit the sprite sheet in an image editor so the tiles are not touching each other with their own color expanded outward
Or use a program like Aseprite that can add padding to sprite sheets
Or assuming you don't want to do that manually and aren't an owner of Aseprite, try the atlas method
https://docs.unity3d.com/Manual/class-SpriteAtlas.html
which layer do i select?
@zenith pier Those layers are used for physics and 3D culling masks
Canvas elements are sorted by order in hierarchy
Sprite renderers are sorted by these rules
https://docs.unity3d.com/Manual/2DSorting.html
Again, do not mix canvas and sprites unless you know what you're doing
Pixel perfect camera. Sprite atlas. Hours opon hours to make a suboptimal system on your own. Change grid size to 99.99. etc, etc, etc.
my sprite is currently able to stick to the walls if the player holds a/d, im using a polygon collider for the triangle, does anyone know how i can fix this?
https://i.gyazo.com/af4c36598403a9b0624105ae378d2398.mp4
VERY new to unity so sorry if i dont understand
how do i make the child sprite of a gameobject (sprite) scale with it?
1st image: unscaled sprite, 2nd image: what i hope to achieve when scaling, 3rd image: what happens when i scale
I've Dm'ed you a possible physics collider solution.
It's best to post solutions so others can see them as well
And only bring stuff into DMs when another user specifically wants that
if that top image isnt really clear then heres the full sized version^
is there a possible way to make a animation with 2 images i have?
That's pretty vague.
Wtf is that?
Still fairly new with the 2D tools here. My camera is set up to reflect a Gameboy resolution (160x144) using the Pixel Perfect component. I've set up a tilemap with the attached image, where tiles are 16x16. The import PPU is 100 and I've set the Grid component cell size to .16 x .16.
Everything SEEMS to be looking right - is it?
I was having problems where the tiles were much smaller than the grid size, and I've seen it suggested that this can be fixed by changing the PPU on import... but this doesn't seem to work with the Grid component.
Any way to import video with a scaling setting like Point (no filter)?
keep grid size to 1 always
the only thing you ever need to change is the sprites
@elfin sandal
Are we talking Cell Size or overall scale?
If I set the Cell Size to 1, things kinda fall apart...
change the sprite ppu to something else then
With the Cell Size at 1, this is the PPU at 20 (I'd go to 16, but it completely swamps the screen):
This is the PPU at 50:
I can't seem to reconcile the PPU sizes with the grid spacing, @elfin sandal ...!
how can i make the shadows look sharper?
It really seems like changing the cell size is the only solution to this problem...!
it's not the only solution but the easiest one
you'll have physics problems with collisions since you'll be playing at very small units but that's only if you use anything related to physics
I mean, what's the other solution @elfin sandal ? I grant you that, say, a standard capsule collider dwarfs tiles at this scale. I'm obviously going to be using physics as I intend to run, jump, have projectiles, etc. But if I'm using the Pixel Perfect Camera component, I can't change a lot of related values on the camera...
I'm not opposed to doing work here, but I'm not sure I see the correct path through this.
you changed the sprites ppu but did you also change the ppu camera component's ppu settings
might be why
I think you're on the money. Let me mess about with that.
You are 100% on the money. Thank you, @elfin sandal .
no problem 
Tbh there's less math to do with PPU values if you standardize editor grid and grid component sizes at exactly 1
The correct pixels per unit should be obvious then
As well as how many tiles/units the reference resolution corresponds to
Roger. Setting the PPU for the assets and the Pixel Perfect Camera component to 16 seemed to do the job perfectly.
Guys i wonder if there is some tool for procedural generation for Unity of 2D top-down levels? I remember there was something like that in Heroes of Might & Magic level editor or in most recent game like Archevale.
I dont want to reinvent the wheel so can someone pointy me out if heard/know something about this?
I got tiles in tilemaps so something using this.
Topdown engine has a procedual tool
Hey ya'll, morning. I wanted to ask what the "pixel per unit" means when importing a PNG image into unity. What is this value tied to?
How many pixels in the texture go into a unit(one meter) in unity.
I see, so when importing things, the PPU value inside of unity of said PNG image should be set to match the size of the canvas they were drawn in? For example, this one I got here uses aseprite and the canvas size is 288 x 128. What should the PPU be in unity? Or are these not related at all and the PPU is just a value i choose?
It is a value you choose; there is no right answer.
Generally, for a pixel art style you will want to keep it consistent across your assets.
It will determine how large a pixel is in world units.
For instance, folks using tilemaps often base it on that(so that each tile is 1 meter for instance) or based on the size of their character for whatever physics characteristics they want.
Or to fit things into a particular screen size with the pixel perfect camera
Ohh I see. Thank you! Appreciate your patience ๐ ๐
This reference resolution here on the pixel perfect camera (as it says there) should be set for the resolution I want my game to run at? For example, I want my game to run at a 1920 x 1080 resolution (most common monitor resolutions)
The reference resolution is... well, think of it as the screen size you are emulating.
Like for example, to emulate an SNES style look you'd use 256ร224 reference resolution and 8 ppu
I see, so If I'm just trying to display my game for a common 1920 x 1080 resolution at a common aspect ratio of 16:9 I should just set the reference resolution to 1920 x 1080 and keep Upscale Render Texture on, so it adjusts accordingly to the player's chosen aspect ratio and resolution?
Hey ya'll! I have this code here for my character movement (that also accounts for when the player is moving right or left and flips the asset), but whenever I press play, the character is extremely jittery (Its like the camera is shaking or something), as seen in the video. And there is also this error on the console, that I don't know what is. What could be causing this?
Hey all! I'm getting started on my first 2D game, I'm looking to use visual scripting for the bulk of the work. Is GameCreator2 a good choice for helping me develop this? The game will essentially be Texas Hold 'Em
Hey everyone, Hopefully an easy question.. I have multiple images that I would like to be treated as a single object in my assets folder (like a sprite sheet that has been cut). Is there a way I can manually add a group of images together like this?
I don't think so - you'd have to put all images in a single image, then slice them up into sprites
Honestly it is probably easier to just see the effects than to explain them now that you know what's going on under the hood
When the player goes up a slope, they they float in the air. When the player goes down a slope, they don't. I'm using a composite collider for the tilemap.
they are floating on the way down. Try a circle or capsule collider for your player. should help
I'm fine with the way it looks going down, but the player is higher than the slope's collider when going up the slope
or, if you want to do it in an incredibly horrible way, make the player a tilemap of its own, with each pixel a tile
its because your BoxCollider2D extends way past your bird's feet in the front
Now that I'm using a circle collider, the player slides like this
You could just use a smaller rectangle, or even two squares(for body and head)
How would one use an ai image generator for a 2d game.
As in csn it be used to make assets (players / enemies)
guys does anybody know how to make your game NES-stile?
like making pixel art crisp
is this the right channel?
hey
i am trying to put a 3D cube in a 2D game. it is not showing up on the screen? how do i fix that
Is there any way at all to get rid of this warning?
hey
i am trying to use 3D objects in a 2D project
It looks like this
But I want it to look like this
Does the "preferences" button send you to a page with settings relevant to the warning?
Nope, it brings me to a page that is blank.
is there a way i can increase the thickness of this 2D square
what do you mean with thickness? if you mean the scale in the y x or z coordinates you can change that in Transform and Scale
@zenith pier we should write here not in coding
also i could make you a wall if you want
yes please thatll be fantastic
sure my bad
is this ok?
nah its 90% copy and paste
and i make this as a floor, duplicate it 4 times and make walls out of it ?
ask someone else about this i just began coding
sure np thank u!
np
You might not see the sprite as it's huge and away from the camera
Remember to follow tutorials and guides when learning Unity
does anyone have an idea for an simple enemy
@smoky socket
This is?
white is ground and pink are walls right?
i don't know what you want to do so i can't judge it
if the pink things are walls then i would rotate them (top and bottom)
yeah theyre the walls
how do i rotate that
got it, but what rotation values should i put it to
If you are going to scale the asset, keep it under unscaled parent, then you can manipulate it normally.
how do i get those as walls
Transform -> Rotation x, y, z
oh wait haven't read the middle message
just try and error
try mostly with 90, 180, -90, -180
okay thanks
it looks like this now. i just need to put top and bottom tiles
yeah
does anyone know how to create a maze node (floor and walls) using tile maps?
Are there any tools that sort of work like Unity's tilemap palette? Where you can have a set of tiles and then use them to paint/combine them into a new image?
I need to create various sprites from the base tileset so that I can then create prefabs out of them.
I found this, but its' not working for me https://github.com/leocub58/Tilemap-to-PNG-Unity
get error
NullReferenceException: Object reference not set to an instance of an object
TilemapToPng.Empacar () (at Assets/TilemapToPng.cs:113)
TilemapToPngEditor.OnInspectorGUI () (at Assets/TilemapToPng.cs:27)
UnityEditor.UIElements.InspectorElement+<>c__DisplayClass59_0.<CreateIMGUIInspectorFromEditor>b__0 () (at <428cf2118a4b4a5595a2768b8e39ad35>:0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)
anyone know a better way to initialise my spriteshapes? (my linePrefab, is just a spriteShape made into a prefab)
foreach (TransportLine line in transportNetwork.lines) {
GameObject road = Instantiate(linePrefab, new Vector3(0, 0, 0), Quaternion.identity);
SpriteShapeController shapeController = road.GetComponent<SpriteShapeController>();
shapeController.spline.Clear();
shapeController.spline.InsertPointAt(0, line.fromNode.worldPosition);
shapeController.spline.InsertPointAt(1, line.toNode.worldPosition);
}
Probably what the preferences button is for?
Doesnt bring me to anything at all, brings me to a blank preference page with nothing highlighted and some text in the search that doesnt match on the page that its on.
isnt that level design?
In a card game what's the pros of having cards as single gameobject with canvas inside on each one Vs gameobject inside a huge canvas?
why even with point no filter does this look so bad when being sliced
Try setting compression to none, currently itโs set to โnormal qualityโ
thank you so much
No problem
how about tile pallet stuff?
is there a way to make those more crisp
Not 100% sure, the only things I would know to change are the compression, filter, and then maybe the max size if itโs a sprite sheet
If the sprite sheet is larger than that max size itโll compress the image, so if size is the issue definitely try scaling that value up
why cant i see the camera ?
how do i fix this
why cant i see any grids in tile map?
ASK
If i want to make tilemap like harvest moon GBA, should i separate the tilemap or make it 1 complete tilemap?
Hey guys, I am trying to make sprite assets, but when I put the sprite atlas texture into the TextMeshPro Asset Importer, and click create/save sprite assets, they do not show up on the list
The spaces where the icons would be showing are all blank, and I cannot figure out why
Does anyone know?
Why is Unity showing me all these extra sprites? The only sprites in my Assets folder are the colored blocks in the top-right and the ball in the top-left
Likely from some plugin you've downloaded that's using those and are in their own folders.
How can I find this plugin?
Unity packages will be in the packages folder.
oh, duh. How do I manage these? How did they get here? This is a new project I started today so it must not be per-project
They're default packages installed by Unity
How do I get them to not show up here?
You can add, and remove them from the package manager. You can also download and install assets via the asset store from there as well
When I see other people opening this window, they only have their project assets showing. How can I make it look like theirs. I don't want to see a bunch of built-in Unity icons.
Whoops, forgot to reply, mb.
You can't. You would probably have to figure out which package it was part of and remove the entire package if you weren't using it.
I don't even know if those are from a Unity package, I've never seen them.
You aren't using textmeshpro, which is the type of text that scales nicely.
this icon being gray means your scene gizmos are switched off
ASK
If i want to make tilemap like harvest moon GBA, should i separate the tilemap or make it 1 complete tilemap?
Is there a way to add gameobjects to a tilemap palette? Like a barrel that can be destroyed
You mean a gameobject on top of the tile, or destroy the whole tile? If destroy the whole tile then just do SetTile to null on the tilemap (ie tilemap.SetTile(new Vector3Int(0,0,0), null) )
If object on top of a tile then just use CellToWorld to find the world location of the tile and then instantiate the object at that position: https://docs.unity3d.com/ScriptReference/GridLayout.CellToWorld.html
You might want to make a class something like GridObjects to add to the on-top gameobject which stores the associated tile Vector3int position; then you can easily FindObjectsOfType<GridObjects> to later find the on top gameobject associated with that tile
@celest tree Is this the way game developers add crates, explosive barrels, chests and other interactable tiles?
Does someone know how I can keep the zoom level the same on different resolutions when using Pixel Perfect Camera? Left side is what I want the player to see, that's at 1920x1080. But when I changed this to 1366x768, then it zooms out for some reason. This absolutely cannot happen, as I only want to show the exact arena. I'd like to add black bars, but all of the "Crop Frame" options don't really fix the problem. Letterbox adds bars on top/bottom, but you can still see more of the screen on the sides. Pillarbox does the same vertically. And Windowbox makes the game a tiny box in the middle. Any ideas how to fix this?
Make sure u check run in edit mode
There's no run in edit mode in the URP version of the component. It's always active
Try changing the button to a differebt color and see if the color shows up
Anyone know how i can make it so these grass tiles have no collisions?
Official? Do you get a badge?
hey anyone has a tip so solve this tilemap problem???
Can you describe what the problem is? Otherwise I'll just assume gremlins.
yes of course! i am trying to make a smooth map for my 2D game and i would want to stop little "islands" like the ones in the screenshot to appear.
i have different parameters for the procedural generation (celular automata) but i can't figure out how to destroy these
Set filtering to point in import settings
o thnx
HOW TO OPEN A SP`RITE SHEET?
like i see people have a thing with their sprites and they click it and can place them
WITHOUT HAING TO DUPLICATE
having*
why is my character transparent a little bit, i know its not the character fault cuz it looks like my character in piskel is visible and the only thing transparent is background and also i disabled the transparency in my image and it was still transparent, i also have urp
Set compression to none, just below where you cropped the screenshot
I'm having some trouble with my sprite rotating when it runs into small collisions (these grass tiles will not have collisions in the future), is there a way to lock the z rotation in the capsule collider component? Or does it need to be done in the script? Rigidbody?
Nevermind, got it to lock lol
do they havei colliders?
`
anyone have ideas on how i can remove the collisions from these grass/flower "tiles"
You want to use separate tile maps for foreground, background, etc.
Okay, thanks
Change the physics shape in the sprite
If u dont know how google it
show your script?
You'd want to lock it in the rigidbody
is anyone familiar with the pixel perfect camera? please let me know if so
Alternatively, why don't you just ask whatever question you have?
Fair - I'm in the beginning stages of making a megaman based game. Looking at recent entries, I see Shovel Knight reportedly built towards a 400x240 resolution, which is pretty non-standard. Yet, it's able to scale to 16:9 seamlessly for 1080p. I'm not sure how to accomplish this with the various settings in unity - I also don't know how they did it. I can set the pixel perfect camera's target resolution to 400x240, but then I have to select the "crop to x, y" setting, which ends up letterboxing. Maybe that's fine? Either way, when I go to build settings and set the window to build to 800x480 & allow for window resizing but select 16:9 aspect ratio only, I find that I'm still able to resize the window's height and width independently and make all sorts of crazy resolutions.
I'm not sure where my approach or understanding is breaking down here, so any guidance will be appreciated. Thanks in advance!
Also, I couldn't get anything that seemed to make any sense at all without the "crop to x, y" setting. Without that checked to on, I would get all sorts of arbitrary sizes included in the game viewport and couldn't properly plan out tiles that would be in the viewport.
@stiff hamlet The first step is usually to read the manual and/or look at tutorials
Use 'upscale render texture'?
YEIA
found how
anyone know why im having this weird texture overlap issue? im using an object as a brush with a texture on a tilemap, and i know the cubes arent overlapping there flush, but i still get this texture bug, anyone have any fixes?
my freeform light doesnt make the character have shadows in different sports of the light
its inconsistent
hi guys, how to apply exception in tile_rule when in edge canvas? should i add more until outside canvas?
like this?
hello guys, I'm new here and to unity too, I wanna ask a question about pivot point, I have changed the pivot point and it keeps getting changed back, idk why the pivot point keeps following the last order of my assets here. I have spent hours and still can't fix the pivot point
From where are you changing the pivot point
Hierarchy or sprite editor?
hierarcy, since idk why my assets doesnt have sprite editor
If you do it in the hierarchy, the changes will be overwritten by the animator if you have one
You could show the inspector for the body part gameobject and the body part texture import settings
this is the sprite editor from my imported asset using psb file
ooo i have animation
so they do have a sprite editor
You can see the sprite pivot point as the blue circle
but i put it in my character gameobject, even when I remove all the prefab, it still apllying to the lowest asset, which is really frustating
I don't quite understand
yes I change all the pivot point to the corner, except for the body
I have removed the prefab, and it still applied to the lowest asset there
like they are not in the middle
and idk why the legs suddenly fall off too, after I remove the prefab
omg thank u bro, i removed the animation, and now all works well
Custom physics shape in sprite editor
you're creating many many little rectangle colliders, apparently
You'd have to make just one, click on one corner and delete, move the remaining three into a triangle shape
There's no such thing as a hitbox, to my knowledge
The physics shape you created will be used as the default Polygon Collider shape when you assign such component
Polygon Collider 2D
Moving characters don't really need an accurate physics shapes or benefit from it, and it's tedious to update the polygon collider component in case of animated characters
I suggest one of the primitive colliders instead
nah im making a game with no animations
im bad at animations
so only 1 frame
thanks
Still it's rarely worth the effort, and the only result is irregular and unpredictable colliders most of the time
Almost every 2D game you can find uses just rectangles, circles or capsules
But that's up to you
You probably don't need the collider to be pixel perfect
i will try both
If you really need the collider to match the pixels, there's a script that can do that automatically
https://github.com/RandomiaGaming/Unity2DPixelPerfectCollider
does it work in 2021.3
unity
Probably
Pretty easy to find out
doesnt work
Enable read/write in the texture as it directs you to and it will work
i deleted an old rock asset and it turned into this? anyone?
hey im making a characted and when i import him to unity his colors are messed up can some1 help pls
Disable compression in texture import settings
thx a lot
how to make a tilemap that uses traps?
like im making different traps like spikes saws
so different collidors
do i have to make multiple tilemaps?
or what
Hi! I don't know if this is the place but.. as you can see here, the bullet is going behind the wall because of Y sorting (the walls pivot is at the bottom) It should go behing it when shooting from above, but not if shooting from the bottom. I cant move the pivot because its correct like this so the characters go behind it as they are supposed to. How do you approach this?
Does anyone know what could block the 2D Shadow Caster to block the use of its edit button?
You have 'use renderer silhouette' checked.
So that'll override the shape.
if only it were that simple ๐ฆ
funny thing is, it does become available when I try to run my scene, and then it reverts back upon stopping.
So I tried copying the values while in Run mode, and it does seem to work
but then I get null exception galore the moment I select anything else ๐
Huh, odd. I've not used that component myself to test
I'm gonna leave the lighting for what it is for now, it's not a high priority yet
how can i offset my tilemap so the tiles are the correct size and line up with my chess board
Sorry, quick dumb 2D question - can I use the Tilemap / Grid to place enemies from a palette onto the grid or am I just placing enemies, players, objects etc. in the default manner? Newish 2D user here.
Hey guys I have a prob with skinning editor. I created a bone and it should be attached to the sprite that is selected like in the image but when I select the bone and the sprite and click auto geometry it doesnt move at all. The sprite doesnt react to the bone!
Hi,
is it possible to make a circle sprite in a unity3D project ???
I cant find it under create > 2D , the only option is physical material 2D
Hi
does anyone know if there is shadow caster for tilemaps?
Or how to implement something like this?
Hey, how would I make it so that my parallax background is behind my grid for the tilemap? I've tried putting it below the grid on the hierarchy and it didnt work.
Rendering Layer and Order in layer?
Elaborate please ? I'm very new still
In the backround image or sprite component should be something like this
sorting layer and order in layer
just add layer called background or change number to higher
that didn't change anything in relation to my grid :p
ah
I figured it out
thank you very much @vague smelt
np
can I get gameobjects from a tilemap via cell position? I Tried GetInstantiatedObject but it returns null. Should I just implement IPointerDownHandler on the gameobjects instead of the tilemap?
2D components are sorted using these rules in order https://docs.unity3d.com/Manual/2DSorting.html
Hierarchy order only applies to Canvas UI elements
Does anyone know how to get ruletilemaps working easily for a 2D platformer
idk why but i find it confusing
Did you add weights?
So, I get how the rule tile works for 3x3 tilesets, but the tileset i'm using is a 6x6. Is there any way to make it so that the rule tile will autotile with a 6x6 tilemap?
I'm struggling to find an answer to an issue I'm having with Rule Tiles. I have a game with two tilesets: grass and spikes. I've created a rule tile for each of these separately, as well as a Palette for each.
First off, I'm not sure this is the correct approach, so please let me know if that is my issue.
But my main issue is I'm trying to get these two rule tiles to work together. i.e. a spike tile will detect a grass tile next to it and factor that into it's rules. As you can see, right now they don't work together and I'm trying to figure out how to resolve this.
L response, i tried couldnt find any good documentation
yeah you're mad weird for this, bro didnt ask to ask he just asked lmao
my first pixel animation
vs my third (after watching tutorials) the tutorials i watched were rly well explained by "BAM animations" who give a very good explanation of the fundamentals of animation
I think I fixed it, I dont really know how materials work
just shuffeled them around until it worked
nice
thats how it looks like in unity
oh
kk wait lemme check something rq
at least it works :D
its super smol tho, can I just make it bigger in unity or will I need to do it in another program?
i just scaled my player object up and if you need to just change the hitbox
OH I KNOW
my square guy works now!
nice
oh I can scale it up...
Okay
Im just
dumb
no dont do that
why?
theres a better solution
cause scaling it up can cause some wierd positioning stuff that can mess up stuff
i forgot what its called but im opening my unity up rn to find out what its called so i can tell you how to fix it the proper way
its 1/2 loaded its pretty slow
ok\
click on the player sprite png
go to inspector
click on pixels per unit
and whater pixels ur character is change it to that
im guessing your character is 32x32
so just put 32 into the pixels per unity
then the sprite should be normal
there
if its blurry just tell me, if not then just leave it alone
np
is it blurry tho?
cause sometimes when you do that it makes it blurry so you have to change the filter to "point (no filter)"
nope
alr then your good
also google is ur best friend for problems
i learned that from a youtube video
and trial and error
and i also look at unity forums
those help a ton
i have one month experience with unity
so i have a ton of issues
i am actually stuck on my project rn and am waiting on a forum reply bc im having camera issues with trackign the player
maybe a year or two if you make it a smaller version with everything a little bit more minimal
do you know why it has these wierd borders?
I just installed these from the unity assets thing
send a screenshot of your inspector for the png
this?
ok ill compare to mine
its not really that important, I can use my square guy
now that I know how to scale him up
or down
naw graphics are important in a game
did you just drag and drop the png into the game scene?
cause i cant find a difference
my game is basicly 3 platforms and a script that allows player movement that I stole from a yt vid lol
Usually due to not using correct material for sprites
to the player sprite renderer
oh ok then thats not it
how to fix?
Yeah hes like the best youtuber ever
Do you have the same issue?
he replied to my problem in like 12 mins
no
Also it seems that flipping doesnt work for me
from the yt video
but thats probably a code problem
yep, it was a code problem
a very simple to fix code problem
anyways thanks a lot for the help
35min past!!
time flies by so quick
wtf
is there an app to make assets like that
so in pixels
that you can color a pixel in by clicking on it
Pretty sure almost all drawing / image editing programs work that way
Some are specialized for pixel art, like Aseprite
is there a way to know exactly on which pixel a sprite/object was hit?
or at least the general location where on the object so I can approximate the coordinates of the pixel
I know there is a way to know in terms of worldspace
for context I am trying to recreate the disintegrating barrier mechanic from the original space invaders but I have no clue how to solve it
You may want to use a destructible tilemap or individual gameobjects for the barrier
Unity doesn't really deal with "pixels" like old 2D game engines do
@modest cargo I was gonna do individual objects but having to line up smalls sections of a sprite would be such a pain
if I don't want to just have normal squares but simulate some progressive breakdown
but destructible tilemap? ๐
that sounds pretty interesting
Individual gameobjects wouldn't be my first choice, but in case you do need to line them up quickly and accurately you can hold the V key to enable vertex snapping
It lets you drag corners of gameobjects and snap them to corners of other gameobjects
I assume it would work if all my sprites have the same dimensions but my other approach didn't have that
so you'd do destructible tilemaps @modest cargo ?
That sounds like the best option here
thx
unfortunately it won't be like how it works in the original game but I am not competent enough to write my own pixel based collision system yet
How will it be different practically?
Unity is a 3D engine through and through so I'd probably favor some other engine if authentic pixel physics are the goal
I mean the way I am doing it now is it would just remove a 4x4 chunk of the sprite overall and it wouldn't look like dynamic destruction like in the original
but I don't really care anymore
as opposed to smth like this
Why not treat individual pixels as tiles?
I'm not sure how the tilemap handles tiny and dense grids like that, but it's surely worth a try
not sure if I would run into similar problems I had when I tried to manipulate the sprite pixels directly
but it might be worth a try, even if it sounds like a lot of work :P
I would have to destroy tiles based on direction of impact and also destroy tiles around it in a "realistic" enough fashion
What kind of problems are you predicting?
That's exactly the kind of thing tilemaps should be suited for
Well, I have to research destructible tilemaps in general first anyway
I know how normal ones work to a degree
Actually I know nothing of tilemaps
@modest cargo since tilesize depends on unity units as everything, how would I even tell it to be a 1px x 1px tilemap o.o
This depends on the size of your "pixels"
Which is the PPU value of your sprites
If you want to skip all the math, treat one unit as one pixel and set the sprite PPUs to 1
But I recommend that only if your play area isn't much larger than one screen
The PPU can be anything, but it's most useful to guarantee that tile sprite graphics have a specific resolution
But since you use pixels, sprite resolution is not a meaningful concept
drawing tiles that small didn't seem to be a problem but I wonder how collisions will work
although for some reason with the tilemapcollider attached the collisions don't seem to work
did I forget something
OnCollisionEnter2D doesn't fire
ah, it's possible that the collider type isn't working
Type not working?
on the tile asset itself you can set collider type from none to sprite or grid
grid works though, at least it generated a collider
now somehow have to figure out how to destroy single tiles
tile destruction works but it's VERY inaccurate so far
sometimes tiles get destroyed and some don't, hmm
but it almost works
How are you getting the tile from the collision event
private void OnCollisionEnter2D(Collision2D collision)
{
int contactAmount = collision.contactCount;
for (int i = 0; i < contactAmount; i++)
{
ContactPoint2D contact = collision.GetContact(i);
DestroyCells(contact);
}
}
private void DestroyCells(ContactPoint2D contact)
{
Vector3Int pos = _tilemap.WorldToCell(contact.point);
_tilemap.SetTile(pos, null);
}
that's more or less the only thing that makes sense
things that affect which tiles get destroyed are the speed of my bullets and the max tile change count on the collider
the odd thing is, it's always the same tiles that don't get destroyed
I'll try if continuous collision detection changes anything
the ones on the left don't get destroyed for example
is there no way to move my game view if I zoom in btw
As I suspected though, the collider is not working properly
I have a feeling it might be too small/dense?
Middle click + drag I think
Or the scroll bars
Assuming you mean the zoom function of Game window
Is it one tile per unit, or denser?
So a 16x16 sprite?
If one "pixel" is 16 pixels per unit, that implies your tilemap is 16 tiles per unit, assuming one pixel sprite per tile
which sounds dense to me
it's pretty dense yeah
so no way to do it in play mode?
Perhaps not by normal means
I never thought about that
The game object based approach worked
Also, worth noting that what your projectiles are and how you're moving them has a significant effect on their collision accuracy
I move them like so
_rb.velocity = shotDirection * _shotSpeed.Value;
shotDirection can be Vector2.up/down/left/right
That's good, means you can use continuous collision detection
Moving objects by other means than forces or velocity has a negative effect, and all moving colliders should ideally have a rigidbody
good to know I did it right yes
Hey, I have 2 questions how to fix some things, first thing is that when I have 2 tilemaps and floor map uses normal map texture, which is sometimes visible through second tilemap created for walls. Second thing is how to make player above this shadow so it will not be clipping player
i want to do uv-mapping with uv editor like 6 sided cube but there is nothing i can choose. what is the problem her?
noob alert
I've looked everyone for an answer, but I think I'm using poor wording.
I have these huge spite sheets to decorate my interior with, and I was planning to just chop it up and drag what I want into the scene, but Unity breaks them up in such an unorganized mess.
is there a window, an organizer? Something to help with this?
or is there a way to make the images larger in the project viewer
That you're asking in here instead of #๐ ๏ธโprobuilder probably
Hello,
I'm trying to make a checkered rule tile, so when I draw, it automatically makes like checkerboard effect.
This is what I've setup, but it's only green.
I was hoping someone could point me in the right direction?
Is there any way to add these "exceptions" with rule tiles?
I want to add a different slope tile that doesn't get auto-placed but it still affects other tiles in the rule tile.
right now, I made a different tileset with the sloped pieces, but its not affecting the rule tile set.
Anyone know what I should do?
I'm running into an issue I was hoping I could get some guidance on my tilemap. I have the tilemap collider 2D attached to my tiles, my character does not fall through the ground, but he is able to pass through the sides of tiles and I'm not sure exactly why. If it's a slope, he'll go up the slope but if it's a sharp increase I intended to be jumped over, he can just walk right through them.I may be using the wrong terms when searching but I can't seem to figure out any answer to what's causing this and what I can do to fix it.
I figured out what the cause was - I have freeze position x checked in my constraints. I'm not sure why that causes me to be able to pass through walls though.
If your character's rigidbody position X is frozen, that means it cannot move sideways by velocity or any kind of force, including push force from collisions
If you can move at all, that suggests you're using some type of incremental teleportation to move (such as .position, .Translate() or .MovePosition()) which ignores rigidbody physics
Yeah I was using .Translate(), I switched it to .velocity after doing some more research. Finding out the X position was frozen was the cause helped me look into it a little more
It's my second project not following a tutorial so I've got a bit to learn ๐
You should always be looking at tutorials and guides
Even if not following them, but using them as notes
They are not "training wheels"
Oh no I meant not a guided "This is what we're gonna make, and now make a script and put this code in it" tutorial.
Unity lost pixels/lowered the alpha of my sprites. Is there a fix for that?
The first image is from the Unity Sprite Editor and the second one is from the software I use to draw stuff.
Do you have the compression set to none and filter set to point?
Yes, but even then, these settings don't affect the Sprite Editor.
The max size setting reduces the resolution of your sprites, if they're above the limit
Is there a way to increase it?
Should be in the inspector somewhere, I believe the default value is 2048
The option should be right under the filter setting
Ho it's that thing. I though it was just working in game, not in the Sprite Editor.
Thank you very much
is it possible to regenerate the polygon collider so, when a sprite mask is added, it will redraw the collider to match?
or just some way to make other objects ignore the bits being covered by a sprite mask
I've been researching a bit more and it seems a bit futile to redraw polygon colliders based on the sprite mask, but now I've found a thread here: https://forum.unity.com/threads/2d-polygon-collider-clipping-by-mask.1220580/ that seems to do exactly what I need it to
OP says they solved it by "using layer masks" without elaborating, but I'm not sure exactly what they were doing with said layer masks
their results seem pretty great so I'm curious if anyone has an idea how they did this with layer masks?
they did mention the Clipper library but unless I'm illiterate, they don't say they actually used it to get this result
Can anyone help?
Although I don't recommend upgrading beyond LTS versions, I heard that overall glitchyness of 2D lights seem to have been reduced in 2022.2.
Including the glitch of it randomly ignoring shadow casters or disappearing
It may be worth the try to upgrade a copy of the project
I agree about how vague the post is
The user seems to be active still so hopefully they'll reply to my message
This normal map glitch still happens
Any other issues improved?
Idk but I think I know what is propably causing this
because I have custom shader for vision (Game only renders where I look), maybe it does something wrong in this custom code
because it looks like on default lit 2d material it doesn't happens
That very heavily implicates your custom shader
Always helpful to start with those kind of details
We have no way of knowing what custom assets you have that could be causing issues
I can send the code of it
btw it is not mine but from someone's vid I think
It has 2 materials vision entity and vision background
And it just changes the last blending style to it
Is it intended to be used with Unity's 2D lighting? Or is the lighting custom too?
unity's
it is copied lit 2d shader and added extra things to it
https://www.youtube.com/watch?v=XWMPEE8O05c It is his shader
I had this idea in my mind for quite some time now and recently I had some free time. So here it is I guess.
Source code:
https://github.com/aarthificial/darkwood-vision-effect
Support me on Patreon:
https://www.patreon.com/aarthificial
Art by "Omnihunter" project:
https://opengameart.org/content/top-down-basic-furniture
Gameplay by Nokzen:
...
Okay nevermind somehow fixed it by adding normal map to wall texture
Does anyone know what I am doing wrong?
Hey, as soon as I enter animation mode, changing the position/rotation of my sprites doesn't work anymore, see the gif:
Here you see that afterwards in fact the transform is successfully animated, just the sprite is not updated
Hey people! I am having a silly issue. I am working with URP 2D and set up many polygon colliders configured as triggers on my scene. I found out that the reference sprites were off position by some little amount, so I moved them back where they are supposed to be, but now of course all the triggers, owned by an other game object, are off position by that same amount. I saw that i can offset them, but I would like to move them all in the right position while keeping the offset at zero. Is there a way to achieve that?
I mean, other than rebuilding all of them from scratch or moving them point by point to the new position...?
If you don't want to rebuild them manually I think the options are
- Copy the collider to a separate child gameobject and move that instead, a bit hacky though
- Remove the polygon collider and add it again, which should generate a new one based on the sprite's physics shape
I think option one is the one for me then, my little squared brain can't accept to have such offset though. I might have to offset the triggers, then write an editor script to add the offset to every point and then set the offset to zero...
A little uncomfortable, but it will be useful in the future I guess
Thanks
I stress again that if your sprites have physics shapes from the sprite editor, a newly added polygon collider will use that physics shape
If the result is valid, you won't need to do any manual work
They are triggers manually placed on the scene, not physics colliders, unfortunately
Triggers and colliders are created the same way
But if they're not based on sprites I think it's not an option anyhow
yes, but they are not shaped around sprites, they are manually shaped
Yes they are triggers like "when the player moves here make that happen"
it's a bit hard to describe the scene structure, but the key is that these triggers are not shaped around sprites
Thanks indeed, the idea itself was good if that was the case
It gave rise to the idea to create and store polygon colliders polygon colliders as sprites for more flexible iteration, in case I anticipate a similar situation ^^
is it possible to generate shadows from a tilemap collider?
2d shadows are kinda really annoying lmao
How do I trim sprites without changing the center pivot assigned from a grid slice?
I guess you could change just the slice bounds
If that doesn't work, could try defining a custom outline
Or hot swap the sprite sheet with cropped versions if all else fails
i exported so that my rotating sprite stays around a 64x64 grid, trimming makes the pivot of the sprite the center of the sprite area and not it's original grid slices
Try custom outline next
I don't see the point of cropping just the slice bounds anyhow, unless you need the sprite sheet space for something else
Well, I think the more meaningful response may be why do you need to crop it in the first place exactly
i was under the impression the sprite bounds determined the hitbox
"hitbox"?
for collisions
"Physics shape" in the sprite editor defines the default shape of a polygon collider component assigned to the same gameobject
If your sprite shape is "tight" it should be perfectly cropped to begin with
Other than that you'll be using primitive collider components which I think also take their initial size from the physics shape, but you'll often customize those anyhow
Or create generic variants
@normal river One more thing to note is that no type of collider adjusts to animation automatically
The shape is only considered at the time of adding the component
so i got to change the outline tolerance to 1 for each of these and generate each manually?
or will this work:
You probably don't need to
That's the "custom" physics shape
With tight type sprites I believe it'll generate one with default settings even without doing anything manually
ah ok
That's the skinning editor, not related to physics I think
But again since the polygon collider doesn't respond to changes like animation, I expect you may want to use a generic primitive collider instead
At least what I would do is build colliders from boxes and circles in the shape that matches well enough all animations, and when they don't, keyframe the colliders to match
Polygon colliders can also be keyframed iirc but it's kinda tedious and pointless
Players often prefer predictable colliders over precise ones
Define 'this' in this context?
The mesh box maximizes on frames without pixels, if Iโm to use this as a hit box itโs gonna cause a ton of problems
Is that the physics shape or the sprite outline?
In either case I suppose you could just disable the whole sprite renderer (or just the collider) on empty frames
Rather than displaying "empty frames"
Guys i'm using multiple tilesets to make a layered map, do you know why when i zoom in and out some layers disappear and reappear?
How are you sorting their draw order?
i haven't done anything, just created a new tilemap when i needed another layer
then the order is by the actual order of the objects in the hierarchy
Hierarchy order is not used for sorting sprites, nor for tilemaps under grid component as far as I know
https://docs.unity3d.com/Manual/2DSorting.html
I recommend you spearate them by Z position or sorting layer
If they have the exact same 2D sort order, the editor will basically pick their order at random
I sent this a few days ago and I'm sorry to repost it but it's probably something stupid that would be more equate here
I would assume that the sprite is too small relative to camera size, and the view on the left is zoomed in using game window Scale
It's also possible that there's problems with the import settings, but it's hard to give a precise diagnosis on an example that's had its context cropped out
It's a 16x16 tilemap
I just stared building the world and in the game tab it like not rendering as if it was low res pixel based
I can send a more detailed screenshot after school
did u use pixel perfect component
It likely might, but it depends on what the issue is precisely
i jsut got home so now im loading up unity
ill send a screenshot of my project in a min
here it is
here is the camera setings if that helps
okay so it was jsut the fact the camera was way to big compared to the sence lol
i made it big being that i was gunna make a huge world map
Resolution, camera ortho size (and game window zoom) are very important for how pixel art is displayed
i guess i jsut expand it as the project gets bigger?
Ultimately you cannot display more than one sprite pixel in one screen pixel, or distortion will ensue
im sorry but i have no clue what you mean
If your monitor is 2 pixels by 2 pixels, how are you going to display a sprite that's 3 pixels by 3 pixels without loss of data
oh wait do you mean its try to expand it but because its one pixel thats not posible to - yeah i jsut realized it sometimes im a bit slow
It's a very common mistake ^^
To render pixel art perfectly, you'd have to make sure that each sprite pixel matches each screen pixel precisely, in position, rotation and size
Basically it means that sprite size / pixels per unit value, ortho camera size and screen resolution must all have a very specific ratio
so jsut expand cam as i grow the world tilemap
No
The camera size must match the resolution of your sprites, regardless of the size of your level
You can expand it to zoom out, but then the pixels get mushed together again
so make it 16 being that im makeing this is 16x
but then jsut move the camera to show difrent parts?
That's the right direction, but required math is much more complicated
Realistically you have two options
Learn to use the pixel perfect component
or give up anything being pixel perfect and just eyeball it so that it's good enough
It's not enough to get the PPU values, ortho size and display resolution to the correct ratio, you'll also have to restrict sprite positions to pixel increments
The pixel perfect camera component does all that and more
id like to eliminate any blur and warping so i guess lean the pixel perfect thing
https://blog.unity.com/technology/2d-pixel-perfect-how-to-set-up-your-unity-project-for-retro-8-bits-games
Here's an article that explains what it does and how and other tidbits about retro graphics rendering, pretty important reading in my opinion
https://docs.unity3d.com/Packages/com.unity.2d.pixel-perfect@5.0/manual/index.html
Here's the manual that explains how to set up the component in full detail
yeah that worked, thanks
Third option is to use something like smoothpixels.
I always forget that it's an option
Probably passable enough for most, though I think it's important to understand what causes the problem in the first place
The problem is that Unity wasn't designed with pixel art in mind =p
Which is pretty reasonable since back then there were better options for that kinda thing.
I hope Unity upgrades its Tilemap package so we have a better implementation of Tile Rules, like the one from Tiled/ASEsprite featured in this video:
https://www.youtube.com/watch?v=TL_JZIuydas
Hey Pals! I got permission to share this sneak peek of an upcoming Aseprite update with a brand new Tilemap feature. Mate, I've been waiting for this feature since 2019. It's too good. You're going to love it. Make sure you check for news on the open beta at:
https://www.aseprite.org/
https://twitter.com/aseprite?lang=en
P.S. First 1080p uplo...
quick question why is it I can't activate the snap tool when working in 2d unity and how do I fix it
Can't you just use aseprite and import it into unity then?
You can read Tiled tilemaps in Unity, but it won't respond to runtime changes naturally
Grid snapping is available only when your tool rotation is in world space
Vertex snapping doesn't care
I'm having an issue with a cursor not following my mouse fully correctly and jittering loads
The camera sets its position to the physical player rigidbody position
The cursor sets its position to the Input.mousePostion
This happens nomatter what update / fixed update / late update I put either of these in
I'm unsure if this is the correct place but I believe it's to do with the pixel perfect camera im using
That spider is adorable. And yeah, it is probably due to pixel perfect camera if changing when in the order you are executing.
Lil bro says hi
But yeah if it is a pixel perfect camera issue I don't know if it's one I can solve
Well, how are you moving the cursor exactly?
It seems to lag behind as it is
Sprite renderer on a gameobject i set the position of
"set" how
to what
So literally just transform.position = mouse position
Using Camera.main.ScreenToWorld
Sorry not at pc rn otherwise I'd ss the code
but yeah I've stripped it back to just bare minimum of setting position of the cursor to the mouse
No lerping
the cursor is a parent object with 4 children corner objects if that matters
But the children do not move
Hmm, parenting is the most robust way to attach things together
I would try as a test to disable the cursor script and just parent the cursor to the camera, see if it still seems to jitter
If it still does, the script isn't at fault
If it doesn't, I'd try to enable the cursor script and make sure the moving happens in LateUpdate
Right so parent it first to see
Then I can still set position
it shouldn't affect the script itself actually just parenting so no reason not to yeah good plan
We'll see but I'm not hopeful will check in a bit
hm your plan was a good plan
just having the cursor parented makes it move as expected (no jitter)
and then enabling it following the mouse makes it jitter even if the mouse isnt moving
its almost as if Camera.main.ScreenToWorldPoint(Input.mousePosition) isnt being updated properly even tho its in LateUpdate
and the jitter only happens in the game view with the PixelPerfect camera active
really starting to feel like a Pixel Perfect Camera issue
Probably floating point errors
Youd need to tell your script to move in pixel increments
Or just have the cursor be part of the ui canvas instead of a world object
is there a better way to import tiles into a rule tile? i am using 2d extras in unity to create rule tiles, however manually selecting tiles from the expanded .png is very annoying and also very hard to see since my sprites are 16x16
I find that you can add multiple sprites at once, but only if the rule tile list is empty at that point
for whatever reason
Hi can someone help me
this video I was following on youtube said to add a sorting layer and call it Background and move it above the default layer and move all my background sprites there
but this happens when I do that
but if I move my sorting layers back to default it all shows up
The most likely explanation is that the objects aren't on the correct sorting layers
Anyway, sorting layers are just one type of 2D depth sorting
I prefer to use Z depth instead, but it's good to be aware of the options
https://docs.unity3d.com/Manual/2DSorting.html
yes, right now I use shift and ctrl click to select multiple tiles that I will have to add
While This Helps a lot I don't know why I cant add multiple sprites like this when the list has something.
this is especially annoying since in a [serialized] list field I can add multiple items at once but not in this one
also is there a way to view the expanded .png or attest the sliced sprites in an organized manner like how importing the sprits to a tile map pallet allows you to.
thanks alot friend
The mini asset browser is basically just a project window with a filter for the specific type of asset
Both have the option to change visibility between list view and icon view using the slider
Has anyone got a clue as to why my background likes to diseappear on my scene view and not appear on my Game view?
It needs to be a physical object rather than UI for specific reasons
Even if I round the position to the pp camera pixels it does it
Floating point errors doesn't seem to make sense as it's such a big jitter
i'm using a pixel perfect camera and I have no Idea what to put here, what are these numbers supposed to be? what numbers do I want?
From the doc:
The Reference Resolution is the original resolution your Assets are designed for, its effect on the component's functions is detailed further in the documentation.
https://docs.unity3d.com/Packages/com.unity.2d.pixel-perfect@1.0/manual/index.html
You can also read through this blog:
https://blog.unity.com/technology/2d-pixel-perfect-how-to-set-up-your-unity-project-for-retro-8-bits-games
Sprite not showing correctly? (New to Unity)
what does this error mean
It means that you have an inactive object that tries to start a coroutine
thank you ! how do i fix that?
Don't start a coroutine in an inactive object
how do i make the inactive object active
SetActive(true)
What happened to my sprites after i imported them to unity?
1st pic is before and second is after
If anyone responds, please ping me
texture compression
hey guys ive used the A* pathfinding package and the AI for the enemy to follow the player (pink) but as you can see the path for the enemy is through the walls, how do i make it such that the enemy can avoid the walls? because the enemy gets stuck at random places and cannot follow the player. thanks!
What do you mean by "the" A* pathfinding package
There is no official one
Assuming nobody here is immediately familiar with that system, it may be best to ask in their channels
Looks like they have forums
And as always start from the documentation, if you haven't already
I am trying to set a normal map for the SpriteShapeRenderer fill material inspired by https://forum.unity.com/threads/spriteshape-2d-lighting-fill-does-not-support-normal-map.1257141/. After saving it somehow looks like attached picture. Anyone solved this issue before? (Using 2022.2.9)
private void OnValidate()
{
var renderer = GetComponent<SpriteShapeRenderer>();
if (renderer.sharedMaterial.GetTexture("_NormalMap") != _normal)
{
renderer.sharedMaterial.SetTexture("_NormalMap", _normal);
}
}```
Looked like this before btw
Is there anyone who is using 2D Aseprite Importer? I need help ;c
Hello, i need help with rule tiles (package: 2D tilemap extras), i am currently trying to get my own rules into it, i used https://github.com/Unity-Technologies/2d-techdemos/blob/master/Assets/Tilemap/Rule Tiles/Rule Override Tile/ExampleSiblingRuleTile.cs and i would like to know the tile position, so i can prevent lag as i am working with big tilemaps, by knowing position i can disable all of rule tile functions when the tile is far enough from camera, i know exactly how to do it, but i cant change the rule tile script (this is what it says: The package cache was invalidated and rebuilt because the following immutable asset(s) were unexpectedly altered: Packages/com.unity.2d.tilemap.extras/Runtime/Tiles/RuleTile/RuleTile.cs), is there any way to edit this script?
Not really a 2d question... I'd ask in the advanced code channel about overriding packages.
hey guys! i have a serialized field text mesh pro for my scores in my gameplay scene but i want to display the score in my other scene which is the menu screen. how do i drag and drop the text from the landing screen to my serialised field in the gameplay scene?
scoreLandingScreen is in my 'Landing Screen' scene and i want to drop and drop it to the player game object in the gameplay scene.
hello, how can I change the render order of my tile maps?
Every time I finish editing my tiles the way I want them, which is to have the wall tiles over the floor tiles, they reverse and the floor tiles render over the wall tiles
Tilemaps follow the same sorting rules as all other 2D renderers
https://docs.unity3d.com/Manual/2DSorting.html
But if you're using isometric tilemaps you need to do some extra to define tile sorting by their virtual height
https://docs.unity3d.com/2021.3/Documentation/Manual/Tilemap-Isometric-RenderModes.html
Id like to add empty spots in this ruletile to cover my levels randomly with grass in one fell swoop with the bucket / area paint tool. What's the best way to add blanks spaces here? Just blank game objects, or should I make a transparent tile?
I did initially try adding empty spots in the Size property, but it seemed to really skew the randomness.
Yeah actually, I think i needed to just add a whole bunch of empty ones to the middle, instead of the sides. And an equal amount on either side at that.
I assume these are common questions; so I'm hoping there are common answers. I'm working with an isometric tilemap and am having sprite layering issues. Specifically, I'm struggling with where to put the pivot point on wall sprites.
-
This first issue I'm having is that the pivot is used to position the sprite on the tile relative to the tile anchor. This means the pivot has two responsibilities; one to order and one to place, and they are often in conflict.
-
The second issue I'm having is where to place the pivot for objects that are rectangular as seen in the image. If I place the pivot on the lowest traversable point behind the wall, then sprite layering works when the character is behind. But if the sprite is at the highest traversable position or just simply above the pivot point, but in front of the wall.. The character will appear erroneously behind the wall.
It seems like this just may be a limitation of the engine and I need to adjust my asset creation process to ensure that walls aren't long enough to have the desired pivot be behind and in front of the wall. I just wanted to make sure there isn't a tool or feature I'm overlooking that solves this problem.
It appears the solution to both issues would be to ensure that walls take up the entirety of the tile...
Any thoughts would be appreciated. Thanks!
I keep getting these weird lines between my tiles
If you're not using pixel perfect rendering, tilemaps may show adjacent pixels from the tiles' sprite sheet
If you don't need pixel perfectness and only need to fix that, you can add padding to your sprite sheets between each sprite in an external image editor, or generate a sprite atlas which also has the option to add padding
how do I use the sprite atlas in a tilemap?
or rather, I already tried pixel perfect camera but it didn't seem to work well (camera randomly jumps between different zooom factors, laggy cam movement. I am using cinemachine but I did also add the pixel perfect cinemachine effect which didn't do much
No different than using it for other renderers
Though I don't know the exact details, I assume it just updates all renderers that reference sprites to use their corresponding positions on the atlas rather than in sprite assets
alright, pixel perfect does seem to work now
for some reason
but it makes my camera zoom in more
Pixel Perfect Camera requires you to work with very specific settings or it may appear glitchy
It's a whole workflow designed to emulate low resolution screens and render pixelated graphics accurately
I wouldn't usually recommend it if your goal is not to have a pixelated style
I mean I want to make a game with mainly pixel art style
but I don't want the movement or camera move pixelated
so for the sprite atlas (sry for switching all the time but I think that'd be the best solution)
I packed every spritesheet into it
and then? is it automatically used for all the tiles? bc it doesn't seem to do anything
There's various ways to use the pixel perfect component to control how exactly the sprites are rendered relative to real screen pixels
But it's a pretty complex tool and easy to get wrong unless you know precisely how to use it
I'm not totally sure since I haven't used it for this purpose
ah setting padding to 8 seemed to fix it
If you can find this menu "always enabled" would at least make sure it runs
Vague editor errors may be annoying but are rarely concerning unless they visibly break something
It's as cryptic as it is generic
With luck it'll stop occuring on its own, maybe on scene change or editor restart or something
alright thanks for the help!
hi im new to unity, can anyone suggest a method to learn unity 2d without following tutorials blindly(i have some coding experience in python and I know the basic fundamentals of programing)
https://learn.unity.com/ is the best way
what do u think i should start with?
Because it contains everything you need to start up and has been validated by people with experience.
no, i meant which course
nah its ok
When working with tilemap tiles, movement causes these weird lines to appear, both in the editor and in the finished exported product. Does anyone know what's causing this?
using 2d tilemap extras
Fixed!
Anyone know a good place to get grass/dirt/sand/etc. textures that span large areas? I'm looking for seamless textures that are 1024x1024 - 4096x4096 but represent 50-100 square meters of terrain so that the repetitive nature of textures is not noticeable. I'm willing to purchase the textures, but free ones that I can use for prototyping would be fine also. Everything I'm finding is mostly designed to be repeated every 1-3 square meters and that just doesn't look right.
It's not usually the first option to try eliminate repetition with just one perfect texture
Usually you see the patterns broken up by blending between multiple textures and terrain types as well as with detail meshes, that's how you see it done in 90% of games
In case of monotonous terrain material it's common to combine a low-resolution texture with "detail mapping", so the low res texture gives color variance to the detail map which is only seen so close you won't see the repeat
Even beyond that there are shaders that can break up the repetition, though those are more expensive to render
https://github.com/UnityLabs/procedural-stochastic-texturing
In 2D the concepts remain the same but implementation may be different
Thanks ... While I'm sure I'm going against the grain (which is not a good thing), I wrote a custom shader with DOTS Instancing that uses a 2D Texture Array of biome textures and blends between them based on the biome of each "tile". I hope I didn't shoot myself in the foot too much. I like how games like RimWorld handled terrain that looks natural over larger areas (see screenshot). I'm able to achieve that ... but I don't have textures I like.
What mine looks like so far (the scale is very wrong right now, those dots are trees when you zoom in while the grass texture is spread too wide for what the texture is):
Thanks While I m sure I m going against
Is it fairly normal for a scene to have multiple tilemaps on different layers to show depth, or is there another way to do this?
So add more than one texture per biome and mix them using noise or something?
I might explore other options with my shader later, I found a texture I'm a bit more happy with for now. I want something more realistic in the future, but this is at least moving in the direction I want:
tileset building is pain
I want to make my sprite twice as wide, is there anyway I can do that in the Unity sprite editor?
My sprite editor has some options greyed out as well and I don't know why. Would this help?
Either change the scale intransform settings or the pixels per unit when selecting the sprite file
I can see the seams, but looks pretty good!
You can still have those leafy details you had originally if you want, just make them appropriately small enough and repeat them with variation so the eye can't catch what parts "really" repeat
Like those wavy patterns in the sand example were repeated
They're probably greyed out because a single-type sprite can have only one position within the sheet and only one name
I believe the position in the sprite editor signifies where individual slices are in the sheet, but only multiple type sprites have more than one slice
why does my tile rule look weird am i doing something wrong
this is the way i actually want it to look like
I didn't really love the leafy pattern of the grass before, that was just proof of concept. I want an even more realistic style than this in the future, but this is at least in the right direction for now while I focus on other systems.
This is a png I want to import as an asset into Unity.
When I try, the sprite imports like this:
This pink doesn't appear in the sprite editor and I have no idea how to remove it. Any ideas?
This usually happens when you have a sprite renderer not using the sprite material
My material is default-line
Also, other sprites are unaffected:
I haven't tested out all of my sprites as I don't want to have to format all of them, then remake them, then reformat
What else could it be?
Not sure but your sprite renderers aren't using the sprite material, like I expected
Isn't the obvious first solution to try to swap to a sprite material
Thank you for the help. I though Default-Line was the material in question by I found a new one