#🖼️┃2d-tools
1 messages · Page 12 of 1
(I was hoping to be able to get Palette A when clicking on Tilemap A and Palette B when clicking on Tilemap B)
hi, do colliders require rigidbodies to work?
i have two gameObjects both having 2d colliders on the same z axis, but they're not....colliding?
At least one of the objects must have a rigidbody
Alr i'll add one
Putting its gravity scale to 0 should not affect the behiavor of the object right?
idk if this is a normal thing but my character is "shapeshifted" differently in several places. it seems thicker on the right here
that sounds like a pixel alignment issue
are you using the Pixel Perfect Camera component?
lemme add it really quickly
it snaps your camera's position and Ortho Size so that each pixel in the sprite art is 1/2/3/... pixels wide and tall on the screen
yes
ortho?
I'm assuming this is an orthographic camera, yes
ig, cus it's 2D?
an orthographic camera doesn't have any perspective, meaning that distant objects aren't smaller than nearby objects
without the Pixel Perfect Camera component, your camera's ortho scale can make each pixel of the art not fit neatly into a pixel on the screen
so each pixel might take up 1.5 pixels on the screen
This causes some pixels to appear larger than others
ooook i see i see
idk if the issue is fixed
once i added it, the assets pixels per unit were set to 100, which makes the player perfectly shaped. so i changed it to 25 to fit the scene, the problem was back, so i just changed the resolution to HD and evrything seems to be fine. but i'd have to open the game tab on the entire screen. is this the best solution? ty
Sprite renderers are not canvas components
They will not work correctly with canvas scaling or the rect transform anchoring
Which causes their position and scale to be incorrect
Pixel perfect camera component will only help you if you understand why and how it works, and how to set up your PPU and resolutions
https://docs.unity3d.com/Packages/com.unity.2d.pixel-perfect@5.0/manual/index.html
alr, tysm
sooooo, Im making a dungeon crawler and when it spawns rooms, i have made every room into a prefab. The bad thing with this is that every room has its own 4 layers as its own tilemaps (see image, those are tilemaps). This makes it very laggy when rendering many rooms.
Is there any way to make it only 4 tilemaps to be easier to render. or should i opt to disable unloaded rooms?
How do you know it is the tilemap layers causing the lag? Is it rendering or CPU lag or some other type?
i dont really know, i just speculate that if i spawn 50 rooms... that is 200 seperate tilemaps in the scene
Well profile it, rather than speculating
hmm i guess the cpu main increases a lot when rendering many rooms (but don't really know what that means)
The stats tab is not a reliable way to profile performance, nor is any profiling you can do outside of a build
And the CPU isn't responsible for rendering specifically
Follow these instructions when you need accurate data: https://docs.unity3d.com/Manual/profiler-profiling-applications.html
Disabling rooms that are not in view, or not generating them in the first place is usually smart, but profiling can tell you whether it even offers any performance gains in your case
A tilemap that isn't changing, moving or animating doesn't really need to do any significant computing or rendering
Overdraw might be an issue if you have many pixels of overlayed tilemaps and sprites on screen, but off-screen objects have no impact on that
aaah, Oki thanks ill try testing a bit in a build.
SO what can i do?
Use only images and other UI components on a Canvas
Use Sprites only outside of the Canvas
It's possible to share tilemaps by loading tiles into one procedurally rather than having multiple ones
But in this case according to my experience it would not offer any tangible benefit, and would make loading and unloading the rooms a great deal more complicated
Something to keep in mind even if I think you won't need it
You can test the effectiveness of it by making a scene with huge sprawling tilemaps instead of many smaller ones and comparing the two with the Profiler
what components do I need to use in canvas?
anything under "UI" category of components / gameobjects
yy

what does it means "anything under "UI" category of components / gameobjects" were can i found this
I'm sorry for my lack of intelligence
The top bar of your unity editor has "GameObject" and "Component" categories
Both of them have "UI" subcategory
The new GameObject list also appears when you right click in hierarchy
The new Component list also appears when you click Add Component in the Inspector with a gameobject already selected
You have supposedly been creating new gameobjects and components thus far
I want to adjust the transform on every tile in a tilemap. Is the best way to do this to call GetTilesBlockNonAlloc with the bounds of the tilemap?
actually, I just realized that getting the block of tiles doesn't help; I just need to get a list of positions that tiles are located at
I'm currently doing this:
foreach (var cell in tilemap.cellBounds.allPositionsWithin)
{
if (tilemap.HasTile(cell))
{
// set the transform
}
}
What for exactly? I wonder if tilemap tiles even have transforms
I'm doing The Thing that every isometric tile-based game must do when a level starts
The tile itself doesn't have a transform; it's something the tilemap itself controls
(which was my blunder here)
i was thinking of the tiles like they were individual game objects
so this is probably as good as it gets, unless I can ask the tilemap to iterate over all positions that have tiles in a way that's more efficient than just checking every tile in its bounds
I mean getting the right tile is the easy part, right?
They apparently do have a type of transform you can set per tile
https://docs.unity3d.com/ScriptReference/Tilemaps.Tile-transform.html
I should clarify that I have it working already :p
i just fumbled immediately when asking the question, haha
float t = TimeFor(new(cell.x, cell.y), start, end);
t = Mathf.InverseLerp(Mathf.Lerp(0f, 0.75f, time), Mathf.Lerp(0.25f, 1f, time), t);
t = Mathf.SmoothStep(0, 1, t);
tilemap.SetTransformMatrix(cell, Matrix4x4.TRS(Vector3.up * t, Quaternion.identity, Vector3.one));
tilemap.SetColor(cell, Color.Lerp(Color.white, new Color(1, 1, 1, 0), t));
So I learned this useful new thing for no reason? 

my game currently runs at 500 frames per second so i think the performance is ok
i'll have to see how it scales to a larger number of tiles
and whether the bulk of the cost is in iterating over every possible grid cell, or whether it's in setting the transforms
i should be able to avoid updating most of the tiles' transforms, since only some of them are actually moving around at any given time
Neither sound very expensive, unless reading or writing also involves doing something expensive in addition to that
The top row of my sprite renderer is getting cut off by the pixel perfect camera for some reason
The sprite is 15x5 pixels and is set to 32 PPU
The pixel-perfect camera is also set to 32 PPU
It only does this about half of the time (it goes back and forth as I move the sprite renderer up and down)
ah, interesting: looks like using "Upscale Render Texture" was causing it
i'm not rotating stuff, so I probably don't need that anyway
Probably not, but it's also useful for pixelating any non-sprite things like particles
ah, I think I was relying on that to make my particles appear properly...
Haven't encountered before the ppc cutting off pixels like that
they're very simple (just a few particles that slow down and stop), so I could just do them myself
Technically you can also attach sprites to particles so they will get snapped, if needed
My game view is set to 16:9. When I set my Pixel Perfect Camera's reference resolution from 320x180 to 640x360, more of the screen gets cropped by the letterbox and pillarbox. I don't understand why.
They're the same aspect ratio, and both are smaller than my game view.
vaguely related question: I'm going to draw many tile sprites. All of the tiles should have the same frame and shading overlaid on top of them.
Right now, I'm doing this manually. But it'd be nice if Unity could automatically overlay the frame on all of my tiles. Is this something I could do with an asset postprocessor?
ah, I should probably ask this in #🔀┃art-asset-workflow shouldn't i
Not simple enough to have the overlay on another layer in the drawing program and have it enabled for export?
That's what I'm doing right now in Aseprite
I'm just thinking about what happens if I decide to tweak the shading
i'll have to copy-paste it into all of my other aseprite files
For that I'd consider perhaps "secondary textures" and blending it with a custom sprite shader
Secondary textures inherit sprite reference and UVs so they're handy for keeping multi-layered sprites together
ah, that's a good idea
Iirc separate sprites can share one secondary texture
My tile maps are wierd, some white lines apearing. I am using an atlas as you can see in the video however the problem still apears.
its okay guys i fixed it, turns out "generate mipmaps" was the issue
Cross posting in 2d-tools as technically sprite resolver is a 2d tool -> #🏃┃animation message
Still not sure what's going on
Yes
Someone has good knowledge about animated tiles?
I have a problem
To anyone using the Sprite Editor and the Tile Map Tools is there any features, QOL, or short cuts anyone wants to see added to them. Been working on a set of community tools that is a custom Unity Package and looking for more ideas to implement for the community.
Oh my, DO I EVER.
Let's see... I'm not at home right now for The List but...
- I would really like the old automatic psb layer to group function they took out a couple versions ago.
- a button to create a quad mesh that completely fills the bounds of a layer.
- a button to apply 100% weight to a selected bone without having to go into the slider.
- a way to test/preview bone scaling in pose mode the way we can rotation.
- a binary weight painting brush(solid 100 or zero weight with a hard edge)
- expand /contract point selection.
- saved visibility sets of sprites/bones(say you wanted to save a selection for the arms, or for the back view of a character with multiple angles, and switch between them quickly)
- A better tool for renaming chains of bones.
- set up IK from sprite editor.
- a button to export the generated Sprite Atlas for a rigged character (for creating secondary textures)
- a fix to how shitty /buggy the text input fields in the sprite editor are.
- better sliders. The sliders are bad.
- a tool to scale the entire bone rig. (Useful for when you import a skeleton from an existing rig that might be at a different scale.)
- a way to copypaste skeletons that are larger than the current sprite editor window without mangling it.
- texture filtering settings inside sprite editor.
- a pony.
- weight gradient tool. (Set start, set end)
- option to add a vertex at the root of every bone when auto mesh generating.
If you have any questions about any of those, lemme know! 
Ugh, I won't be home for hours 
Instead of saying creating block tile assets for a 2D isometric map, is there a way to make one big platform I can paint on, so the grass and dirt look seemless? While also being able to add levels?
So this is what I got working already or WIP stuff partially working in the Sprite Editor tooling.
- Select Multiple Sprites while keeping context of the last specific one you selected.
- Seperate context actions for either a group of selected sprites or the last one.
Example got a sprite sheet for a character that has animations. You can select multiple frames and name those frames with one click to something like Player Jump for example. They will be named Player Jump, Player Jump 1, and so forth.
- WIP of being bale to select multiple sprites to change pivot points, pivot point unit mode, and border editing of multiple sprites.
- Tile map shortcuts for quickly switching between Tile Maps in scenes
- Added Tiles default layer so when you selected a Tile in the Tile Palette it auto selects the Tilemap in scene with that sorting layer to allow for easily going back and forth between tiles on different layers.
Haven't done anything with the sprite bones yet, but that list gives me a good set to look into.
What about the pony?
I can give you a meme cyber horse does that count.
Those all sound like good improvements. That method of renaming would be good for bones, too.
- Export sprites as skinnedmeshrenderer would be genuinely amazing.
Anima2d, the tool the 2d animation package was based on, could create skinnedmeshrenderers instead of sprites and there are some big benefits to that.
Has anyone here used vector art in 2d? I’ve downloaded the package and imported an svg file. I can see it but it doesn’t react when I zoom in (it stays pixelated). Any ideas on how to properly implement vector art?
The svg package imports svgs as rasterized textures. If you need realtime vector rendering you'd need something else.
Or if you just need smooth scaling, sdf might work (like the textmeshpro shaders)
Yeah I’m looking for smooth scaling
guys any idea or videos on how one can make 2d map(top view) of the places like university and schools?
Could you give a little more information on that. Are you meaning interior with no roof appearing or something else.
If you can share an image for reference it could give a good start
Which type of skinned mesh renderer are you meaning? I am assuming you are meaning the 2D bone System since you mentioned it before, but I just want to double check.
There are three main types in Unity. Skinned Mesh Render for models, Skinned Mesh Render that uses Point Caches to bind VFX/Shader effects to it, and than a Skinned Mesh Render using 2D Bone System.
Sprites can be exported to a 3D model Skinned Mesh Render to do some interesting flip book VFX effects that follow along a mesh. Seen some 2.5D pixel art games that use this to render out a fire VFX flipbook to go along a bow string for a skill effect.
In all honestly all three can be done.
some easy way to convert a tilemap into a single sprite/Texture2D 1:1. I did a wonky implementation of it myself lately, but it is pretty fragile, so a more robust and efficient way to do it would be wonderful
I meant the first specifically, for the particular reason that there are a million things you can do with that kind of mesh that don't support skinned sprites. The second does interest me, but I don't have a specific need of it(though I'd probably find one!). The third option is just what unity already has, right?
There are a few ways to do that, so don't think that would be hard to do.
sure, but having a simple utility with a few configurables built-in to the engine would be helpful
Ah that is what I was meaning. Adding one for people to use would be simple. Thinking about making it an option in the Tool Overlays for when a Tile Layer is selected.
Oh yeah, generate it in-editor and save as an asset, then people could automate a process like that when re-painting a tilemap (think tile-based minimap etc.) or use it during run-time, if for whatever reason these tilemaps can change during the game
that would be a pretty expensive function computation-wise, so some warning about using it on Update and so on in the documentation would be nice. I can share my solution for inspiration if neccesary!
I am thinking something like that could use Burst and the job system depending on how it ends up being done behind the scenes for in editor function to speed it up
sounds like a fun way to potentially learn some basic array and pixel-oriented programming as well as some parallelization in a not-too-complicated and visual fashion. I'd love to see the result of that, I might try to make something similar myself
Is this for editor only or also shjould be able to spit out something for Runtime.
First thought would be able to spit out a thumbnail for any game with a level editor tools system built in.
I think both, where you can specify what should it be saved as if in-editor and potentially force-overwrite or just create another Texture2D/Sprite asset with a name+1,2,3...
And during runtime it would be more as a way to quickly apply some effect on this new jointed sprite etc. That's what forced me to create my own solution anyway.
Another potential use is if someone wanted to easily create some pixel-based editor in-game (clan flag etc.) they could also use this
Just sparking ideas
pixel-based editor as in paint but with a smaller defined grid so that people can customize some clothing/banners etc.
any ideas why none of these game objects are showing despite them all being set active?
the Player 2 GameObject you have selected on the screenshot has no SpriteRenderer or anything similar attached to it, so until then its just a lonely point floating serving no purpose. Do you have those components added in one of the child GameObjects?
yes
where the camera is they should be
theyve been scaled to the UI
since I placed them inside of a canvas gameobject
if that makes sense
Are these elements supposed to be a part of UI?
no
i placed them inside so I could reference all of one phase of the game, at one time
if that makes sense
so i combined the UI canvas parent with the scene gameobjects
so the Canvas GameObject/component is supposed to be used only for strictly UI-related components, like buttons, HUD, menus etc. How are you currently referencing those different elements then?
their parent is also the canvas gameobject
all of those gameobjects are also inside of the same canvas gameobject vvv
but they work as normal
the slingshot is not a UI element, as well as the red line renderer
if you need anymore info ill give im desperate to fix this 😅
Issue with that is, you see the canvas and all UI elements use whats called a RectTransform, which really works correctly only for screen-based operations (scaling, correct relative positioning etc.) and will often break when used for anything else. I would start with having each of these objects, like the slingshot not parent from a Canvas. Then you should see a small 3D/2D toggle in the upper-right corner of your editor view. This will show the actual z distance of each object in relation to the camera
I'm suspecting they somehow got misplaced behind the camera or behind that main background image
so how could I remove an object like this, from it's parent canvas, without breaking it's position?
i tried just dragging it out of the canvas, and yeah, it disappears
that's sort of expected, once you drag it out and make sure that this slingshot object is independent from the Canvas, you can double-click it in the hierarchy to focus on it, scroll out and put it in the same place
(I'm sure there should be a better way to do it, but this will do)
double clicking it shows me this
and changing the z values doesnt make it appear
do you see the 3D toggle in the upper-right corner of the scene view?
yes
doesnt show me what im looking for
i dont know if im being difficult, but I really don't see it after searching for it
if you focus on the slingshot in the 3D mode, are you able to see it?
and what renderer is attached to it?
this is really interesting, can you show the full editor again when looking at the slingshot? Also try to rotate around it, just to make sure the scale or rotation don't make it wonky
it is invisible, my camera is supossedly right in front of it
this child object has the sprite
'Front'
putting it back into the canvas object doesn't make it reappear
are you positive none of the parents along the tree don't have a RectTransform? like the P1 attack UI? You need to make sure these types of rendering/placing components are separate from eachother entirely
the ui parent does have one
when I said independent, I mean you should consider placing each object in the hierarchy in relation to what is truly a part of UI/Player/Enviornment as all children move along with their parents
yeah i will from now on
I asked in unity talk and no one knew if they should be separate so I just did it
I imagine your code is oriented around whatever this is, but all gameobjects that are actually part of the game world should not be under any UI parent, and vice versa
yeah that was the idea
but I can easily change this
but in terms of retrieving these objects?
do I just need to re make them
i have the previous instances in the unity version control, so if you know anything about that, id really appreciate knowing how I can take the old asset back
A common practice is having one main Canvas component, where all its children are separate Panels/UIs enabled and disabled as neccesary, all Enviornment objects under an empty ENV GameObject and so on. I see you have some SerializedField members in your classes. If you reference a component the reference should stay there after re-arranging the hierarchy, and it should be an easy fix otherwise
yeah, i will re arrange the hierarchy, but do you know what the fix is for getting them back in the scene?
If you mean the invisible objects, I would solve the SpriteRenderer-as-child-of-UI issue first, ensure the Rendering Layers are correct (disable all other sprites except the one you check), and making sure, that they aren't placed behind the camera
if your sprites are not empty images, doing each of these i mentioned above you should see them back at some point. Just make sure you dont have some Canvas or RectTransforms as parents, and they aren't always rendered behind your background for example (checking RenderingLayers is what will verify it)
sorry is there any chance you could give me the step by step
- most simply drag the slingshot or whatever object you cant see out of the hierarchy to not have any parents, place them away from any other object (you can always see the transform manipulation tool)
- if you still don't see it via the normal 2d camera view, enable 3d, focus on it, rotate around it, scroll in and out a little to make sure it's not rotated/scaled away from the 2D camera direction
- if you still dont see it, try creating a new object with just the sprite renderer with the same sprite next to the invisible one, and simply look for differences
let me know if that makes it clear for you
it worked 🙏 when I singled out the sprite renderer, but is there a way to get the positions back, which isnt completely manual
otherwise, I did one bit, so it doesnt seem to difficult
if you right-click the slingshot object before de-parenting, perhaps some option there? besides that I know you can do it via code
glad to be of help, just make sure to seperate UI from gameworld/physics-based elements in the hierarchy to avoid these and many similar issues
yeah will definetely do, your a legend
I now referenced the UI bits and scene bits separately, what if they have a joined parent which has a normal transform component, is that a bad idea. UI parent and scene parent would be joined under one parent
so 'p1buildUI' and 'p1buildObjects' under 'Build'
is there a specific reason you want them under one parent?
to shorten this
and the code
but if it would cause the same issue as what I already had, ill just leave it
i would rather ask myself if there is not better way to break this down, perhaps a Player class that has a BuildObjects, UI, and so on referenced separately? It's mostly about how you wanna design the system of your game, but if you want to have something running, I wouldn't try to fix issues you don't have
Important part is you have it going, you can always go back and improve or polish, but don't be discouraged becasue you don't always use the "best" solution. The best solution in this case is one you can have working and you understand why it works
yeah definetly, thanks alot
Hello I am working on a 2D pixel art game and wanted to do the pixel art by myself so I found that GIMP was a good free app to make pixel art but when I use it on unity it is blurred. Could someone help me ?
Probably your texture import settings. The default settings are not meant for pixel art.
in texture import settings, set Import Mode to Point (No Filter) to get 1:1 what you import, this usually solves it
"Filter Mode"
Also, any compression tends to mess up pixel art
Hi, how can i make my pixel art sprites snap to a grid which is the size of one pixel?
So that every sprite aligns to the grid automatically
message me
Why would that be preferable to just answering here?
Google unity grid snapping. You can resize the grid
Also make sure the PPU of the sprites are correct
And look into pixel perfect camera
Thanks a lot i will try when i can
Oh thanks it works !
Thanks, ill try that out!
If you need it at runtime, pixel perfect camera definitely
If I'm creating sprites and the main character is in a 48x48 canvas, is there a general size that people use for tilemaps? Do they keep it consistent (48x48 in this case) or is a smaller canvas size usable such as 16x16 32x32? Take SOTN for example. What is it's tile size? I know Alucard is ~48 pixels high
hi o'm using the sprite shape renderer and this question can seem stupid but how can i remove dot please
For exemple in this case i just want to delete some but don't knwo how to do it
If you click on a control point and hit delete, it deletes that point.
Yes thanks I fond it I was trying to hit backspace
hi , i have some issues using the tilemap, im not sure if its a bug or if theres something wrong with my code. i was hoping someone could check it out before i submit a bug
Hard to check it out without knowing what it is
ofc 🙇♂️ let me describe it:
i have a 2d game. it uses a tilemap. the tilemap is filled with tiles. i want to delete a random tile in the tilemap and i want to lower the tiles on top to replace the deleted tile (think of it like a tetris effect). then i want to fill the space on top with a random tile. The problem is not all tiles are getting filled. so im left with holes where some of the deleted tiles are.
i have the project there below. i tried to keep it as simple as i could while still displaying the potential bug:
I might try to demonstrate the issue in #archived-code-general first
With that many moving parts I guess the error could be in many places
I don't know how deeply the Unity QA teams are willing to dive into scripts but I expect they want the problem well isolated to prove it's not in one of your scripts
thank you, im in #💻┃code-beginner right now, maybe i should switch to general?
I would stay in beginner because that's where the conversation is.
Sorry for redirecting you here btw. Shoulda just kept it in one place
np
I have a 9-sliced sprite with a custom physics outline and a polygon collider, the collider aligns as expected by default, but when I turn on auto tiling a slope forms.
could I get some help in preventing that slope from forming?
I'm having a wierd issue where my tile palette brush disappears when I flip the tile.
As you can see, I can rotate it without any issue. Any time I flip with shift+[ or ] the tile vanishes like a null tile
The version is 2020.3.19f1 btw
Is there a way to get a Free Aspect-y game view that always has an even resolution?
Odd resolutions mess up the pixel perfect camera
I like being able to mess with the game view to make sure my game actually works at various resolutions
You can predefinw multiple resolutions and switch between them instead of using free aspect?
I believe that you can set it by code but not sure how the ppp adfects it so eady solution is easy =p
does anyone have a good recommendation for a software for making sprites?
The course I'm on uses krita, but I'm personally a fan of paint.net
Both softwares are free
Any image editor of your preference will work, but if you're making pixel art, Aseprite is unparalleled
It's cheap and also has the free Libresprite alternative
Is there a way to get HDR-colors as the material color for sprites?
For use with post-processing effects like glow and such
Not directly
It operates using vertex color data which is in 0-1 range
HDR color needs to be unclamped
I'm making a 2.5D game using tilemaps. I'm using custom axis sorting order with Y axis, and it works fine for everything else, but when I added a diagonal wall it breaks, because for a diagonal object, the Y value comparison is not enough to determine the sort order. Did anyone have that problem? Any tips on how to solve it?
it is, until diagonal tiles start giving you headaches
you shouldnt reinvent the wheel, there is a rendering sorting layer in all Renderer components. You can also add a custom "sorting group" component to override it. Just use those layers properly and you should be good to go
as for documentation literally google unity <Renderertype> sorting layers and go
maybe try making the tiles smaller so it won't make so much difference on the Y when you walk along the wall
the wall is too wide so the Y value is so different on the 2 sides of the wall
make each tile as wide as the player
I might be missing some point you're making, I'm still fairly new to Unity, but I believe that just the static assignment to certain layers/groups doesn't solve this issue. There doesn't exist a single assignment that solves it, because for a diagonal wall, the sorting order needs to change whether the player/objects are positioned behind or in front of the wall. And my question is what's the technical solution to determining that. I'd be very happy to use the cookie cutter solution here, I just don't know what it is.
well, all the tiles are standard 128x128px size and making them smaller would be a lot of work at this point, would surely make the situation better but I don't think it would solve the issue in a consistent way, I'm afraid I would still need to solve weird edge cases
You don't have many good or simple options besides "don't let the player get too close to the wall"
As mentioned isometric sprites are sorted by Y position, but even on the same Y value a diagonal wall lets you get in front and behind it
I guess the only other option is to make your own custom sorting system that depending on the direction of the wall it will calculate the X too
It might not be a huge hurdle, as Tilemap Extras shows how to do scriptable tiles to change their order in layer or swap to a variant with a different pivot + offset, but it's some extra steps
I'm sure there were many devs and games that had to solve my issue, I'm really not trying anything unique here.
probably I'll have to make a custom sorting system (although that doesn't really answer the question of "how" 😅 )
Cast a ray or checkCircle on the feet of the player. If it hits anything other than the ground, change the sorting layer of that object
If it hits the ground it means there is nothing else. If it hits anything else it means we must not see the player
And cast won't detect the player
hmm interesting idea. This gets complicated though because there are multiple objects in the game, moving platforms, teleporting boxes, etc. which all can be either in front or behind the wall
but I guess maybe it could work? I'll think about it, thanks
I still think the usual way is to make every tile same as the player width if the world is not giant it won't be too much tile i guess
It's always been a challenge
Games with similar perspective preferred to avoid diagonal walls when possible
I suggest a scriptable tile that compares its position to players' and changes sorting layer or pivot
No need to rework the whole sorting logic of every object to use the new sorting method then, only the problematic ones
Another solution that I’ve seen in games relies on not being able to approach any wall from both sides, this way you could have a seprate layer „over” the player and another one „under the player. Another assumption realtively easy to implement would be not being able to hide „behind” the walls at all. Then all you need to co is cast a ray/small box ar the player’s feet to stop them from walking onto the wall and under it. Hope it’s clear somewhat, but as others stated without some hand-crafted workaround you need to restrict yourself somehow and think what you want to achieve with these diagonal walls
How can i make a car be able to rotate fully and look sort of 3d-ish in a top down 2d game. I've found sprite stacking and i like how it looks but there are close to 0 tutorials on how to achieve it in unity asides from gamemaker studio,
Hi, Im not really much of programmer, despite knowing what i want and ChatGBPTing the code but
I've always wanted to create a small Peggle Like project, The hardest part seems to be the Peg placer. ive tried a few times in the past spawn pegs along a spline but it was never seamless.
I was wondering if its possible within the Unity tools, using the Sprite Shape Package or Spline tool to create a Spline of Pegs that can bend and distort according to the spline, each with their own Properties and segmented Edge Collider 2D.
I was wondering if anyone has achieved something similar.
I've had a bit of a fiddle with the Sprite shape and can see how to put a texture on there, and a single edge collider to see how it would fit. But i dont see anything in the documentation that would allow me to segment areas of the Sprite shape with individual gameobjects like peggle.
Is this possible within the existing unity tools or will this require a fair amount of supplementary code?
Any info would be much appreciated thanks
you want it pixel art? otherwise it's difficult
yes pixel art
do you know how to make the sprites first?
because the main part is to make the right sprite, the programming part is easier
i have the sprite part sort of figured out, i dont know how to plug it into unity
The splines package(not sprite shape) includes an example of doing something like that.
first put all the sprites in a parent as a 'stack'.
every layer must be 1 pixel above from the other
imagine it 3d
if the tire of the car is low, so the Y level should be low
its like pixels of a Voxel
and then rotate each layer in their own position(don't rotate the parent)
https://www.youtube.com/watch?v=_Z5eg9UvLRw
I got the car sprite from this video
Learn how to create stacked sprites in Godot to create a "fake 3d" look.
To create sliced sprites, you can use Goxel or MagicaVoxel to create a voxel and then use the "export slices" option.
Code: https://github.com/jontopielski/sprite-stacking-tutorial
Car Sprite: https://github.com/jontopielski/sprite-stacking-tutorial/blob/master/CarSlices....
Okay, its simpler than i thought. Thanks so much:D going to go try it out
I looked through the examples but they were all 3D
All objects(except UI) in unity are 3d.
Including sprites
Hello,
I am working with 2D Spriteshape and I want to apply gradient to open spline. When I apply shader to it, I am getting segmented gradient over spline. You can see sesult on image below, my goal is same look as has linerenderer. Material with gradient shader is inserted to Edge Material property and spriteshape has default settings.
How can I achive it? Thank you! 🙂
If you are using v8 or higher, you can edit the uvs with custom geometry https://docs.unity3d.com/Packages/com.unity.2d.spriteshape@8.0/manual/CustomGeometry.html
Hello, first of all thank you very much for your response! 🙂 I looked into documentation/examples and I am little confused 😄 Do you please have any tips, how I could create it? Thank you 🙂
I haven't attempted it myself, I just know that it is possible. Though you might wanna look into the sprite shape controller class, I believe there might be an option for stretched UVs built into it now that I think about it but I don't recall whether they actually enabled it or if they simply talked about it as a future feature...
hi can somebody explain me why does this happen? this tile should not spawn right there and especially not in between the tiles. should i send a screenshot of my rule tile?
hello?
it's better if you send
Hello,
my question is probably stupid, but I use the Spriteshape package and I create platforms with it. My spriteshape profiler has two sprites set up (two variants). At some point in the game I will change the spriteshape sprite on an already created object. If I understand it correctly, I need to create a script that will loop through all the controll points and set the sprite variant on them. Or is there a simpler way how to set it?
And my main question is: It is possible to animate change of the sprites (variants)? Or is variant sprite change only instant?
Thank you for help and have a nice day! 🙂
made 2 screenshots bc it wont fit on one
^I could still use some help with this problem up here
hey guys, how can i see camera borders?
Hey all so I am using a asset pack for the tiles in my game. They were all put into one file so I sliced it in unity but I have a problem where some wall tiles are split into 3 different ones. is there an easy way of having unity place all 3 parts down at once when I place it or am I stuck doing it manually
Swlect camera in scene view and hit f?
anyone know if I'm doing this wrong? for some reason I cant drag the sprite into the rule tile "default sprite" box
figured it out, unity just being weird.
Hey there, I've got 2 Sprite Renderer objects with 2 different sprites, one a x128 and one x256.
Is there any way for these to automatically scale to the same size, or will I need a script to adjust them on a case-by-case basis
Anyone know how to fix the whole things to make them joined? I know with rule tiling (because of a yt tutorial) stuff take priority but ive been following everything down and idk why the stuff is still like this
fixed it I really should expirement a bit more before I ask questions lol
can you tell me what is the best program for desidn 2D sprite ?
Can someone help me with tile maps? i use composite colliders yet it sort of bugs my player out
not sure what do you mean by automatic
but you can change pixel per unit
what is the bug?
I can send a screenshot
ok
I need to edit them so you can see whats going on
I cant really explain with screenshots, but ill try
The cat first thinks its jumping (It plays the jumping animation when idle)
Here is on a normal cube
And a tilemap:
If you someone could help
It would be very appreciated
can you show the script related to animation?
In your dms?
did you make it with on trigger enter and exit?
you can send it here too
i guess you used trigger enter to check ground?
Here
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityStandardAssets.CrossPlatformInput;
public class Character : MonoBehaviour
{
private Rigidbody2D rb;
private Animator anim;
private float moveSpeed;
private float dirX;
private bool facingRight = true;
private Vector3 localScale;
// Start is called before the first frame update
private void Start()
{
rb = GetComponent<Rigidbody2D>();
anim = GetComponent<Animator>();
localScale = transform.localScale;
moveSpeed = 1f;
}
private void Update()
{
dirX = CrossPlatformInputManager.GetAxisRaw("Horizontal") * moveSpeed;
if (CrossPlatformInputManager.GetButtonDown("Jump") && rb.velocity.y == 0)
rb.AddForce(Vector2.up * 200f);
if (Mathf.Abs(dirX) > 0 && rb.velocity.y == 0)
anim.SetBool("isRunning", true);
else
anim.SetBool("isRunning", false);
if (rb.velocity.y == 0)
{
anim.SetBool("isJumping", false);
anim.SetBool("isFalling", false);
}
if (rb.velocity.y > 0)
anim.SetBool("isJumping", true);
if (rb.velocity.y < 0)
{
anim.SetBool("isJumping", false);
anim.SetBool("isFalling", true);
}
}
private void FixedUpdate()
{
rb.velocity = new Vector2(dirX, rb.velocity.y);
}
private void LateUpdate()
{
if (dirX > 0)
facingRight = true;
else if (dirX < 0)
facingRight = false;
if (((facingRight) && (localScale.x < 0)) || ((!facingRight) && (localScale.x > 0)))
localScale.x *= -1;
transform.localScale = localScale;
}
}
I guess you can simply fix it by changing the
if (rb.velocity.y > 0)
anim.SetBool("isJumping", true);
if (rb.velocity.y < 0)
{
anim.SetBool("isJumping", false);
anim.SetBool("isFalling", true);
}
instead of 0, use something like 0.1f
Okay i will try that
Should i use 0.1 for each?
yes, for both use 0.1f
Now it always displays the running animation
Do you know the fix to that?
Oh no thats the falling animation
you only changed the 0 for the velocity.y?
don't change it for velocity.x
Ill check
Do i change all 3?
you dont need the y == 0
if y > 0.1f
{
is jumping true
isFalling false
}
else
{
is jumping false
isFalling true
}
use this instead of that 3
Like this?
wait
I was trying to summarize
if(rb.velocity.y > 0.1f)
{
anim.SetBool("isJumping", true);
anim.SetBool("isFalling", false);
}
else
{
anim.SetBool("isJumping", false);
anim.SetBool("isFalling", true);
}
use this
now you need a method to check if the player hits the ground
it's not right to check if velocity.y == 0 to see if the player is on the ground or not
so you need another way to cancel falling animation
Ok
actully if you do this you don't need that 0.1f
keep everything just change that 0.1f to 0
sorry for making it complicated
Its completely fine, thanks for helping
do you know how to make a ground check?
you can use raycast
you can use layers too
✅ Get the Project files and Utilities at https://unitycodemonkey.com/video.php?v=c3iEl5AwUF8
Let's look at 3 different methods for doing a Ground Check which is a necessity if you're making a Platformer.
If you have any questions post them in the comments and I'll do my best to answer them.
🔔 Subscribe for more Unity Tutorials https://www.yout...
Thank you
when you complete this, you can cancel the fall animation when the playes is on ground
Although how do i fix 'The modifier private is not valid for this item"
where does it say that
can you show the script related to that
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityStandardAssets.CrossPlatformInput;
public class Character : MonoBehaviour
{
private Rigidbody2D rb;
private Animator anim;
private float moveSpeed;
private float dirX;
private bool facingRight = true;
private Vector3 localScale;
// Start is called before the first frame update
private void Start()
{
rb = GetComponent<Rigidbody2D>();
anim = GetComponent<Animator>();
localScale = transform.localScale;
moveSpeed = 1f;
}
private void Update()
{
dirX = CrossPlatformInputManager.GetAxisRaw("Horizontal") * moveSpeed;
if (CrossPlatformInputManager.GetButtonDown("Jump") && rb.velocity.y == 0)
rb.AddForce(Vector2.up * 200f);
if (Mathf.Abs(dirX) > 0 && rb.velocity.y == 0)
anim.SetBool("isRunning", true);
else
anim.SetBool("isRunning", false);
if(rb.velocity.y > 0.)
{
anim.SetBool("isJumping", true);
anim.SetBool("isFalling", false);
}
else
{
anim.SetBool("isJumping", false);
anim.SetBool("isFalling", true);
}
private void FixedUpdate()
{
rb.velocity = new Vector2(dirX, rb.velocity.y);
}
private void LateUpdate()
{
if (dirX > 0)
facingRight = true;
else if (dirX < 0)
facingRight = false;
if (((facingRight) && (localScale.x < 0)) || ((!facingRight) && (localScale.x > 0)))
localScale.x *= -1;
transform.localScale = localScale;
}
}
I left the . in by accident, i removed it but they are the errors i get
is your fixed update and late update inside of update?
i think so?
they must be seperate methods
like
Update()
{
}
fixedUpdate()
{
}
one after another
ok
!code
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
Hello, we're making a 2D top down puzzle game, my artist wants to be able to paint environment details directly in Editor, on texture in 2D. We know Unity has tools for painting directly on 3D terrain, is there an equivalent for 2D?
Hello! I am having this very weird issue. I'm just hovering the tile somewhere and it breaks tiles in other places.
Does anyone know what could be going on?
You'll need to be more specific. It would depend on the type of object you want to paint on, and what you want to paint onto it.
The terrain painting tools paint on vertices, even though the data is saved as a splatmap.
So do most painting tools like the polybrush.
You can of course make your own texture painting tool if you need one.
it'd mostly be used to paint non-gameplay, non-asset decorations, like grass variations, flowers, stuff like that, non-repeatable details
yeah making my own texture painting tool sounds like an overkill, and also we don't have 3D objects so we dont have vertices
I was wondering if there's something obvious that everyone would use for this use case (2D game)
What kind of objects ARE you using? It looks like the map is largely bespoke already
In my own game I just make stuff like that into sprites and place them generally.
so this is the gameplay concept, we're using sprites, everything you see within the wall would be some kind of a sprite. But outside of the walls there's plenty of room for decorations, some of them as tiles, some of them as decoration assets, but the rest could be made by just "hand painting"
Just hand painting sprites is probably your best bet. The way I'd do it is to take a full sized screenshot, take it into your paint program, and do your additions there on a new layer.
Then bring em in as sprites.
Also, for the soft blobby lighting you use on the exterior, you can get a lot of use out of a single blob sprite that you place all over =p
Rather than making bespoke blobby patches of sunlight
Sidenote: sprites do have vertices(four of them, at the corners), so they are affected by vertex shaders. A slight world space noise to the vertex positions can add a lot of easy variation to grass and flower sprites.
ahh, I will repeat that idea to the artist, thank you for your comments!
A single gradient circle blob sprite is used for like 90% of my lighting and shadows. https://i.imgur.com/TMioDmr.mp4
Though I also have a couple variations, like a noisy one and a cutout one.
specifically this one
Helloo
Somebody may know what's going on with my character rig?
When I add a limb solver to the feet it works properly
But when I do it with the arms, it also adds the chest bone
And it shoulnt't, arm bones are sons of the chest bone, but legs as well of the pelvis and doesn't happen the same issue
Just the arms. Is there a way to exclude a bone?
Limb solver uses three bones. Your arms have two bones.
So add another bone, either at the hand or at the shoulder.
Has anyone used SVG's as tiles? I'm having trouble rendering them inside tilemaps
you can't drag and drop an svg into a tile pallette to create a tile.
Hey All I am using a tile map for my game and have this tile thats sprite extends into other tiles, but keeps its hitbox which is what I am trying to do is have the player render on top of the tile when it comes from the bottom but is rendered under the tile when coming from the top. how can I do that?
Hi, I'm having an issue where my tiles are larger than the grid they're in. How can I change the size of the tiles?
nvm figured it out. Had to increase ppu
how could one set up a rule tile such that it copies the orientation of the tile above or below the tile being placed?
That doesn't sound like something rule tiles do
They determine a tile based on whether there are or are not adjacent tiles in specific positions
*Custom rule tile
I'm not super familiar with custom rule tiles
Do you have something working there already?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Tilemaps;
[CreateAssetMenu]
public class Wall : RuleTile<RuleTile.TilingRuleOutput.Neighbor>
{
public int tileType;
public string tileID;
public override void GetTileData(Vector3Int position, ITilemap tilemap, ref TileData tileData)
{
base.GetTileData(position, tilemap, ref tileData);
Vector3Int otherTilePos = new();
TileBase tile = null;
for (int i = 0; i < 2; i++)
{
otherTilePos = position + Vector3Int.up * (i == 0 ? -1 : 1);
tile = tilemap.GetTile(otherTilePos);
if (tile != null)
break;
}
if (tile != null)
tileData.transform = tilemap.GetTransformMatrix(otherTilePos);
}
}```
This is what I have presently, which works as expected when drawing tiles downwards, but it only applies properly when placing tiles with individual clicks upwards
(when holding m1 and dragging, it draws the tileset appropriately downwards (left), but fails to do the same when drawing upwards (middle), placing tiles with individual clicks works as expected (right))
Is this the only way to accomplish this?
Use a RuleTile
mhm
click it
I see it, but I don;'t understand what it does
you can change it to allow for the tile rules to rotate, mirror, e.t.c.
let's say I have a corner tile, I have exclusions to the right and above the tile right?
and I set the center piece to rotate, when I place a tile in the bottom right corner, it'll automatically place the rotated corner piece
kk
here's an example
mhm
(imagine the red lines as the corner's borders)
and it checks all rotatiosn
btw random question but what happens if I do a negative offset on perlin noise?
just swap the xs and arrows on that, forgot to move them around
aight ty
it'll apply the same rules as before, then offset them
Why doesn't the glow work?
What do you mean? What glow
can I have tips on how to make trees on a tilemap not only take up one tile, but 2?
I want them to be bigger
also ignore bad art
If you look in the video, the red bar and text have some glow. But when I play the game theres no glow.
Different postprocessing on the game camera from the editor camera?
In Unity tiles are not restricted to the grid cell
A tile sprite can be of any size and shape, with the pivot determining where it'll be positioned
If your trees need to occupy two cells on the grid rather than just spill over visually that'd be a bit more complex
Is there somthing I have to change on the camera?
Add whatever postprocessing you want on it. Also, you might need to set the ui to camera rather than overlay
Hi I am trying to use the box collider 2D component to stop a sprite from walking over them but it's not working and im not sure what I have done wrong
I have placed the tiles that I don't want the player to be able to stop on in a separate tile map with a box collider 2D component attached
Don't use a box collider 2d with Tilemap. You should use a tilemap Collider 2D https://docs.unity3d.com/Manual/class-TilemapCollider2D.html
I've tried this also but all of these colliders just overwhelm me icl
Even tried looking at yt tutorials using the tilemap collider 2D but it still doesn't work
Does your Sprite collide with anything? Does it even have collision set up?
Yeah collision is set up, it even works when encountering a different tile’s collider to trigger an event
It’s fine though I’m not gonna bother for now
Thanks
Using a 3d light with 2d lighting system?
Ooooh unity tutorial might be calling it the wrong thing
New question
I have the buildings in the buildings sorted layer
Ive told this light not to target the buildings
How can I solve this problem with my character? This was a built-in RP proyect transform to URP to be able to change the Transparency Short Axys setting. I try changing this setting on Y to 1 and -1 but noone of them works correctly. The character and the walls are on the same Layer and the walls are a tileset with a Composite Collider, I just want that the object which Y is lower to be the one that is shown but I don't know how to do it automatically, I suppose there should be any way but I'm a bit new. If you have any tutorial about this in spanish or english i will appreciate
The only solution I found is to segment the Walls to different Object grouping them by their Y value (all the walls with the same Y value in the same group) . But I think this is a bit weird and want to know if there is a propper way to do this
Use a tilemap collider 2d with a composite collider 2d in the same object. Once you had added the composite collider you have to change an option on the tilemap collider to enable it (this option change depending the Unity version)
Ok will try this, thanks!
If you want to modify the colliders with this method you should do that from the sprite editor and change to Custom Physic Shape and set the colliders manually. Once you have all done you have to remove the tilemap collider and add it again, idk if reset component works also
any idea what might be causing this line around the border of my sprite shape?
I'm not really good at Unity, but try with these : https://learn.unity.com/tutorial/introduction-to-the-sprite-atlas#
Even if you only add one tileset to the atlas to pack it should help. Let me know if it solves it, I'm curious
Would games like cult of the lamb or dont starve be 2d? or 2.5d? or 3d? Because Im not sure how to make the topdown view look like that in a 2d space
Hi everyone, I hope someone here can help me. I have a bit of difficulty to wrap my head around how the Tilemap tool works with 3d gameobjects. When I edit the tile palette in XZY orientation the gameobjects show up in XYZ orientation in the Tile Palette window, which makes it hard to see which object i'm selecting.
Steps:
- I created a rectangular tilemap and set the grid to XZY.
- I opened the Tile Palette window, created a new Palette.
- I switched the brush to Gameobject Brush and assigned my gameobject to the Cell.
- I Toggle on the Tile Palette Edit and add my gameobject.
Result 1: The gameobject is viewed from the front, but I would like to see the object from top down view. (First picture) - I tried to change the Cell swizzle in the Tile Palette i created to XZY.
Result 2: The grid in the Tile Palette window show up weirdly. I can only see the side of the grid. The objects are still viewed from the side. Is there any way i can get it to show a top down view when editing the palette grid? (Second picture)
Don't starve is 3d
how can i make this 2048x2048 sprite be resized to the grid tile size?
Change the ppu of the texture
and what should i set it to?
nvm i figured it out
Anyone know how to fix the colliders for my isometric z as y tilemap? I have tiles that are on a higher z value but the composite collider is generating the collider as if the tiles are on the same z plane as the lower tiles
Why is the grid not correct for each tile? I want those grass tiles to be able to clip correctly, but I also want the Tree Tiles to do so as well. How can I fix this?
is there any way to quickly generate the sprite outline for this sprite, because having to manually place points along the right side is giving me an aneurysm
*I want it to be exactly along the vertices of the sprite
what vertices?
And generally the auto outlines aren't pixel precise for various reasons. I remember a couple projects on github for pixel level tracing but don't have links handy.
the vertices of the pixels, because I want the outlines to be pixel precise
those aren't vertices, but this is probably the one they were thinking of https://github.com/sr4dev/Unity-SpriteAssist
How do i connect my health bar animation through unity?
How can i make a 2d plattformer endless runner with tilemaps? Any tuts? I want to generate set levels procedural like Obstacle 1 - Obstacle 45 - Obstacle 24 - Obstacle 32 and the obstacles are made by tiles
No lighting?
huh
yea
which light source should I add for 2d space
that's gonna light up my whole map
It's putting white over my texture for some reason
I had to mark these as normal maps
why my secondary texture didnt have dropdown. im following happy harvest tutorial but i didnt get the dropdown. my editor version is 2022 lts
what dropdown
There are two options. If you select one, then you can only do the other
Try clicking the dropdown on the SECOND one when the first is empty
i didnt have the dropdown at the first place
Huh. I see one in your most recent screenshot. It wasn't there before?
nope, i tried create new project and still not appear
Refresh
Okay i will ask another way.. How can i move tiles without moving the tilemap?
Or is it possible to export tiles to a sprite?
I have this material and it's not showing up like it should be
I drag it onto a square and it just appears grayish
Did it not seem to be a normal map issue?
well if I put it as a normal map it puts a color over the texture
I don't want that, I want it to look how the texture looks
not with some kind of overlay over it
If it does that even as type: normal map, the normal texture may be messed up in some way
The values look like of wrong to my eye
How do I make this look better
I put these manually on this
Define what "better" is, then do that
References help immensely
This level looks to use a tileset with different tiles for walls, floors, ceilings and corners as the shading seems to change in those spots
Once you have such a tileset you can simply paint the specific tiles in appropriate places from your tile palette
what would you suggest for them to look nicely together
make them all the same size and just connect them like lego blocks?
Usually tiles of the same tileset are the same size to begin with
And you probably should be using Unity's Tilemap component
https://learn.unity.com/tutorial/introduction-to-tilemaps
Is there any way to set some sprite to the position of a tile?
I mean, I have a Tileset for the wall, but I want some walls to be breakable with a different sprite and functionality (with a collider, script...). Is there any way to set to a position automatically? Sometimes it's hard to get the exact same pixel of position manually. I try moving the sprite inside the Grid and snapping but it didn't work
how did they put in those torches
and the door
is there any way to put certain stuff infront of other
What torches where?
You can use several Tilemap components, one for each "layer" if tilesets need to overlap
The doors are probably not tilemaps though, since they are so sparsely used there's not much point making a Tilemap for each
Could also be the case for the torches/candles, but the pillars and other background details look to be a part of a Tilemap
A Tilemap is just a tool for easily and quickly placing sprites in a grid
Tilesets are sets of sprites designed to work well in a Tilemap
how can I turn a gif into a texture2d array
I have a bunch of scripted tiles... like bordering on the 600s. Some of them require specific placement in the tile palette to make sense
But. There is no image to drag into the tile palette, it's just a bunch of objects. Is there a way to import all these into a tile palette without killing my hand?
is filter mode point no filter, compress none?
idk ill check in a few minutes
ok im dumb i can just select, but like
how do I make my tiles import into the tile palette in a 14 tile line not in a square?
Hey does anyone know what angles you can move the hex tilemap grid to in order for them to sit on top of the isometric tilemap properly?
how do you mass import scriptable tiles in a tile palette without it all becoming mismatched?
I found this but idk if it's helpful or correct:
I got so excited until I realized it’s chat gpt
Here’s a better question
Why is
the palette import not adjustable
Yep, sorry I didn't specify, it sometimes help but other times is wrong
Who thought it was a good idea to force everything you import into a crumpled up rectangle with being able to change it
I wasted hours last night playing a god damn puzzle to get my tiles in order
Oh yeah, that is a bit shitty, you have to add tile by tile or add all of them and pray, and after that relocate them one by one. Other thing that sometimes can help is use rule tiles and then just add the rule tile to your palette, but sometimes cause the complexity of the tileset it's not posible
This is sad. Is every unity dev just playing PuzzleMania everytime they have large scripted tile sets
It’s funny how this could all be fixed by just allowing a linear import
Well, theoretically you can create an script to manage how tiles are imported to a Palette but I haven't try it. I can give you the ChatGPT answer if you are interested on it
Here you have the message, it shows how to create sime kind of TileImporter, maybe you have to mess up a bit with it, but it didn't looks so hard
Thanks
Please don't post unverified ai generated answers - see the red section of #📖┃code-of-conduct
hi, i have an issue where all of my pixel art sprites are rendering with a weird pixel overlap/double render. This isnt an issue in the original pictures so it is something in my unity editor, i have a screenshot, help pleaase
Have you set the Filter mode to Point and the Compression to None on the Inspector?
i did the filter one, but not the compression
gimme a sec
didn´t make a difference, still there
Your sprites are png?
yep
the weird overlap comes from the filter to point and compression to none, because that are making the blurry bits sharper, but it just turns the blurry bits into rectangles, so how do i get rid of the blur, because there is no blur in the original picture
why is this happening in my sorting
Is this some weird pivot thing I have to re-adjust the entire spritesheet to fix?
the trees and the player are on the same layer, same value, correct renderer settings, on the tilemap, chunk mode, sort order bottom left, player is on sort by pivot
the player is behind all the trees in every spot, it doesn't even attempt to sort
I'm try to get the player in front of the tree, and behind it past a certain point
it actually happens with every sprite so I feel like im just forgetting something
also apparently the higher up the player is it sorts behind everything but if i take it to a tree lower on the map it sorts on top of everything instead
Where are both their pivots? Are you using sorting group components? Custom sort axis is in use?
custom sort axis yes, sorting groups no. pivot of the player is at the feet, and there is no real pivot for the tree because it's composed of 9 tilemaps, all of which have their pivot in the center
Right, tilemaps
They're probably using a "chunk" sorting method specific to tilemaps
yeah I have it set to chunk
Neither chunk or individual sort modes work very well for your style, since you're not additionally using isometric height for tiles
You'd probably be much better off by making the trees a group of sprites with a sorting group to unify their pivots regardless of tree shape
Is there another way? I've already coded all these trees and tiles for seasons
also the weird thing is trees in the middle of the map sort perfectly
also that would be like, every other object on the map too
https://docs.unity3d.com/Manual/Tilemap-Isometric-CreateIso.html
Isometric tilemaps have the option to add a virtual height to tiles so the tilemap can distinguish between "up" and "north"
I can't tell if it's easier to rework your system to using that or to rework it into using ordinary sprites
Your issue is likely only with multi-tile objects
so i guess every unity game just has all objects like trees, bushes, and anything the player sorts on as game objects
or just isometric tilemaps
but that's not really gonna work for me
or any 2D game with an aerial view like mine
Eh, why wouldn't it?
I've offered you two solutions already
One for gameobjects, the other for tilemaps
Everytime I've ever seen them they're always in a totally different view than your average top-down game. I don't think my game would even look good anymore like that and it seems like I'd have to redraw all the tiles
I don't understand what you're referring to
Your style is an isometric style
Isometric often correlates with angled or diamond-shaped tiles, but that's not a requirement
Since you want tiles that use isometric sorting methods, you would benefit from it
But since it also emulates a 3D grid it can be a bit excessive, which is why I'd use simple sprite gameobjects with the sorting group component for this purpose
It is tragic if either of the solutions are incompatible with your current systems, but that is often unavoidable when you learn while developing and tackling problems face first
I think I'll just go with simple sprite game objects. It's gonna be annoying to code an additional thing for that, but it's do-able
I had the same problem and the solution I found is to set the player always to be over the tiles (in my case are walls), then create different Sorting Layers (Wall, Player, UnderAll...). So when the player enter on a Collider with the Tag "Overlap Area", it changes the character Sorting Layer from Player to UnderAll, and when the player exit the collider it set the sorting layer again to the original. I don't know if it is inefficient, but my levels are small and this is the best solution I found. I can show you with an example if you need
For simple Sprites it works fine if you set the Transparency Sort Axis to (0,1,0) but for tilemaps this is the only solution I found, because unity as I understand process the full tilemap as a sprite, so when you are in the down-half of the tilemap it position your character over the sprite and when you are in the top-half of the tilemap it position your character under the sprite
Also I have to say that this is my first game and I'm a bit new on Unity so maybe there is a easiest way to do that, but this is the only working way that I found to solve that problem in my case
im making an 8*8 2d game and i feel like it would look better with outlines around certain sprites. but everything ive tried has failed. i was told that maybe my shader didnt work because my sprite sheet didnt have room between the sprites. but that seems silly anyone have any insight on this?
HOLY THANK YOU SO MUCH
Likely true, not silly
But it depends on what kind of problems you're seeing
the material i make from the shader is distorted. im using _MainTex and added the texture to the shader
Distortion hints at UV issues, which for sprites may be very different than more typical geometry line quads
sniffle I remember not knowing anything and my assets all being crumpled up now I'm helping people here with the same problems I had
Any suggestions on how to give a 64*64 character a bit of more flair and personality? Been fiddling around with a player character sprite and a basic idle pose. But the character looks a bit bland, more like a basic enemy.
Without seeing it, hard to suggest much.
Hey so when I have walls on a normal isomtetric plane my character clips through them when they're slightly lower and when I use Z as Y I can't have my character be in front of a wall at one position and behind it in another. Does anyone know how to deal with this?
so i have this 2d textture that is transparent (its basically a bunch of squares but in the middle they are dark and get lighter (more transparent) if they are more near the sides when i apply this texture to a sprite only the middle squares are showing. how to fix
I made a 16x16 texture for a basic cube but when I try to assign it as a sprite, I get "White Square_0's rect lies (partially) outside of texture. Will not generate Sprite for this slice." Please help me
quick question, how can I duplicate a bone hierarchy? I want to mirror the right arm bones to the left side
CTRL D doesn't work, neither CTRL C / V, nor alt dragging, shift dragging, ctrl dragging, combined alt, control and shift dragging, I was watching a video but the part where this user made the second limb was skipped
the limbs have exact measurements, I don't think I can skip having exact bone lengths as I'll use inverse kinematics and related algorithms later
the copy and paste buttons replace the previous rig bruh
fix that rect to lie inside the texture bounds in the sprite editor?
To differentiate walls and floors in sorting the tiles need different Z positions
https://docs.unity3d.com/Manual/Tilemap-Isometric-CreateIso.html
There are explanations here about the relationship of height and depth axes with isometric tilemaps
Hi. I am currently studying tilemap. I can't get data from tile created with GameObject brush.
When you click on the tile, information should come out.
tiles with a number are a Gameobject
Using tilemaps, I want the table to be in front of all 3 chairs, but the chairs & the table should be sorted by Y against the player and for that they have to be on the same Sorting Layer. How can I solve this problem?
Are each of the chairs and the table individual tiles?
yes, they are made up of 1 tile each, but individually
As long as the pivot point of each character and piece of furniture is at the point where it would contact the floor if it were 3D, then the sorting should work okay with the tilemap in "individual" sort mode
But that gives you less freedom to position them so it'd be better to make them sprites rather than tiles
Tilemaps work best for well, tiles
ye, fair enough
change their z position or sort order based on their y value, set the characters pivot to their feet
Hi, I need help trying to blend two blend trees from different layers, the second layer seems to override the base layer and I'm looking to mix them, I thought that the blending was based on percentage of values or something like that, the additive mode makes the bones completely static, what am I missing?
or maybe I'm trying to use the wrong approach
Might help
My clips only have loop, loop pose and speed parameters, I don't see all of the rest to at least configure the additive pose reference
Can i somehow create a "rim" around solid ground with rule tiles?
The way that the rule tile setup supports is to treat every rim tile as solid tile
And then give only solid tiles a collider / physics shape
As far as rules are considered these three are the exact same type of tile, even though they result in tilemaps that look much different
Correction: these
Which means you can cause a weird spot that's consisting of only 4 corner pieces, even though that there's no "full tile" there
That's not a problem if you're painting then manually, but can be a pain if you need rule tiles for random generated tilemaps
If you need it to work with procedural generation you need an extra system to ensure it works
Yeah, that's what im trying to get it to work with
Then if you go with the above suggestion you would have to ensure in the algorithm that there are no lone solo tiles, nor tile groups of 2x2 since 3x3 is the smallest group that can give the "padded" look
To me it sounds cumbersome though
It might be better to generate first using only solid tiles, then surround them with the edge tiles, perhaps using another tilemap entirely
I've been pondering the same thing but I haven't figured any quite optimal path to it
If you're not tied to unity alone, you might look at tiled. Here's a video kinda solving a similar issue. https://youtu.be/QXeCCvGgHhk?si=6x0IJP1IEi14omrj
NOTE: Since Tiled v1.9 was released, some of the details in this solution are no longer necessary (specifically, region layers can be omitted if you use the new workflow). as always, check your version and the relevant documentation for the most up to date information :)
Hey Pals!
Back with a new video all about Automapping in Tiled, which is ...
I guess wave function collapse would also be an elegant way to solve this in code.
I don't think this will work since i use procgen.
I feel like this would require making a lot of tile variants for tiles adjacent to inner corners
But I'm not totally sure
I'm honestly kind of surprised that I couldn't find anyone else doing this type of thing online
That type of tiling is pretty common for 2D games in general
But just outside Unity spaces, it seems
Why do sprites that are farther back sometimes cover up closer sprites?
Sorting for sprites is complicated!
Ohh, how would I go about preventing that?
Sorting layers, sorting axis, breaking sprites up into smaller pieces, all depends on the specific needs
Remember that the sort is based on the pivot
Ok thank you
how would i make my rule tilesets work with other tiles
i made a stair tile but the rule tileset acts as if it isnt there, how would i fix this?
can i duplicate certain pixels in aseprite?
im making a character and i want to duplicate the legs without having to draw them all over again
for some reason the tile maps aren't rendering based on which is closer, though I don't remember changing any rendering settings. I can change the order of the one in front to one and it will render on top from all directions but idk how to get them back on the same layer
it also works occasionally and in game mode it gets super wonky
even just little nudges and they swap back and forth
it might be relevant that the object with weird rendering isn't part of the active scene even though it's active in the hierarchy
basically they render on top each other in ways that are chaotic and heavily influenced by camera position, as opposed to just rendering one map in front of another
my instinct was rendering layers, but I haven't messed with those
I built them by hand so the instantiation should be fine
so i checked through all of the tile maps and the sort order stuff is default.
I made a recording of the behavior for more visualization
@remote lion You could try tilemap sort Mode: Individual but aside from that I don't think you have many options
2D components are not designed to work with a perspective camera / with 3D rotations
Making an opaque sprite shader could solve it, but you lose all sprite sorting functionality
hey there people! i have a question regarding importing aseprite files into unity, basically im trying out importing my animation files into unity so all the tagged animations are created in the file by unity
however, all the animations that are created from the file are set to read-only and i cannot modify them in the animation tab, does anybody know how i can change them to not be read-only and be able to change the animations in the animation tab?
How good is the sprite atlas for packing sprites these days?
Normally I use TexturePacker but I have alot of 1080p sprite parts that would come out with a bunch of sheets so im wondering if the atlas is a better choice
They are read only because they're controlled by the imported asset
You can duplicate the animation you see inside the imported asset with ctrl+D to create an editable copy
It's a one-way process though so you'd edit them in aseprite as much as you can / need to first
Sprite atlas is good
But 1080p sprites seem to be kind of a special case and are generally kind of awkward to fit in any PoT dimensions
What are they for?
got it! thanks for the solution :)))
Well this will be part of a interactive scene in a VN
No live 2D stuff so everything is actually animated
and of course a lot of the sprites are broken up into only things that change but it still takes up a decent amount of space
TexturePacker sadly doesnt have automatic multi packing for unity but I managed to get everything to fit into 9 2048 sheets
How many 1080p sprites can you fit in a 2048 sheet?
i fit quite alot into 9
208
With that number I'd have to guess those 208 are not all 1920x1080 sprites
thats why i use texture packer
the default files are kept like that for the sake of lining everything up
but all the empty space gets cut off when it becomes a sheet
(its mostly to just make sure it all lines up when its imported)
If you're not squashing or stretching anything you can fit only one 1920x1080 image into a 2K texture
The method of packing can't really change that
How well Sprite Atlas fares versus TexturePacker with the particular sprites you use is up to you to test
It's quite fine as a system though, and there's Sprite Atlas v2 also that may do better
yeah its hard to find comparisons these days on atlas v2 vs the packer
Why not make some?
Anything you might find is unlikely to be relevant to your specific sprites
Does Unity have a built-in component for holding the 2D objects together, like it's done in UI? Scaling the object should affect its neighbors.
In editor or at runtime? "Holding together"?
The rectangle transform tool works for all gameobjects if you select many, not just UI
Usually the way to inherit scalings among many transforms is to parent them under a common transform and scale that
This is not the case here. I want to change the scale of a single child of the transform. This should affect its other siblings
For instance, as you may see in the image provided, making the object smaller should, apparently, change the position of its left neighbor
Why should it? I don't recall that happening in UI
That's why I have asked for a built-in component, which does it
Hmm so like an automatic vertex snap of sorts?
Right
No such tool out of the box unfortunately
Vertex snapping (V) works in editor but not automatically
At runtime you would probably calculate the positions to snap to with a scripts
You probably can use the Position Constraints for that
A transform parented at each corner of the middle sprite, with the bordering sprites positioning themselves relative to that transform using the constraint
I see, thank you
Actually, I have realised that I don't even need this, as my object's positions should be simply updated manually
I usually tend to overcomplicate stuff
that's unfortunate
Add the stairs in another layer
How do I go in and manually edit a tileset? I want to make it a slope.
Nevermind im learned about the custom shape gen
By custom shape gen you might mean custom physics shape
Sprite shape refers to the mesh outline which is a different thing
can somone help me with a tilset?
So i have a tilset that has the normal tiles 16 by 16 but the wawes anim tiles are 9680, 80 96, 80*80 and don t know to get them animated and working properly
By "80*96" do you mean some water tiles are not square?
All I can see there are square, but the rest definitely should also be if you want them to work with your tilesets
Hey, how do I make my urp project with sprites have the sprites actually able to go dark like right now they glow
But like not actually glow they just are not affected by darkness you can always see them
Make sure it is using a lit shader, not unlit
Yeah. That one should be affected by lighting.
Try asking in #archived-urp or #archived-lighting
May get a better suggestion.
Ok
I am trying to make a hexagon tilemap, and I created my own hexagon sprite in photoshop that has a 3d effect making the 2d tile look 3d. I tried to upload the sprite into my tilemap, as I saw in a youtube tutorial, but it stretched the tilemap all weird like this:
I want the hexagon to just fit normally in the grid and have the 3d part go outside the hexagon so it clips with other hexagons if that makes sense.
I am mightily confused. I am trying to make a 2d tile based game. And the units do not match up. I have a tile grid that is size 1 by 1 but it does not match to unity units since a 2x1 unity units sized test sprite is way smaller. What the f... is that? Like it makes no sense. Also I double and triple checked the test gameobjects scaling so its also not a scaling issue either.
How did you determine the size of your test sprite?
Transform scale is not size, it's a multiplier to size
Sprite size is determined by the relationship of PPU value and the sprite's resolution
PPU? I have a 16x32 pixels test sprite. The tile grid is supposed to be 16x16 pixels but what I get is what you see above. I might be overlooking something obvious.
I think you're overlooking PPU
Pixels Per Unit value of imported sprite type textures determines how big the sprite should be made relative to unity units by renderers
That was indeed the case. facepalms
Grids or units don't have pixel values for size, but the same result is achieved by determining unit size relative to sprite
Yeah I was just being a derp and did not adjust the PPU properly.
This enables you to mix multiple resolutions of sprites and to always have a way to make them fit the grid
Or to standardize their size or resolution with each other
Yeah it normalizes them.
Which makes sense, in hindsight. TIL moment. Thanks for your patience.
Could someone explain why the child object can't align properly and how I can fix it? Thanks.
Because those diamond icons are off-center in their textures
The Icon field also has the "Other..." option to use a better custom icon if you feel like it
But usually you can just use the move tool (W) with pivot mode: Pivot and you see precisely where the gameobject transform actually is
Hey guys, I'm looking for some help and maybe someone can enlighten me on this one issue I have
I'm trying to create stardew like customisation system for the player
But to animate each clothing piece I'd need to create an animation for them, anybody know of a solution to work around this?
Making 100s of animations seems tedious and would make a bit of a mess so I'm looking for a better solution to make swap sprites at runtime inside the animation?
Hey there! can anybody help me out with figuring how to fix this? basically i have this issue where the tiles of my map have this weird grid that appear when i move when i build the game!
im using cinemachine with a pixel perfect camera aswell for follwing the player with 0 damping on x and y so the tiles do not do any weird jitter, for the tiles of the map im using a tilemap with a composite collider on them
i really don't understand what is causing this since it only appears in a build and not the scene
Does it happen in Play mode in Game window?
does not happen in playmode or scene mode :(((
idk what's causing it to appear but in unity everything is really nice and smooth with the pixel perfect component no jitter or this weird grid
Which render pipeline?
if URP, then my guess is your build may be using a different quality level that is not using the 2D Renderer necessary for pixel perfect component to work
yeah it's 2D Urp!
i checked but the quality setting is set to ultra for all platforms , im not sure if it's some option that i have to tick for it to usethe pixel perfect component
Not one especially
But you could show what the quality settings tab looks like just in case
my tab looks like this, i tried changing it to ultra for all platforms but the build still has the grid lines when i move, it's also only the floor tiles for some reason, i have the floor tiles on a separate tilemap layer with a smaller sorting order number than both the player and walls and other terrains
maybe it has something to do with the ground tilemap since the walls don't have those lines appear in them, i also use the default pixel per unit of 100 for all my assets
Not with the sprite editor per se, but you can write a script to automate it
how do I make a 2D circle that opens in a circle? like a loading symbol but it just makes a full circle if that makes sense
Not much sense. Have a diagram or example?
ok hear me out
have you ever played cut the rope?
any of the stars that have a timer on them. I want to replicate that
let me find an image real quick
I want this effect
except in reverse
Is this a ui or a sprite?
For ui, you can just set the fill type to radial. For a sprite you'd make a shader for the same effect- just take a regular horizontal fill but apply polar coordinates
Don't assume, it it your game =p
Hey guys, how can I crop the image to just the red rectangle?
This is my prefab. And the component.
UI masking
#📲┃ui-ux
thank you!
I'm having an issue with the skinning editor where when trying to edit the geometry it just shows a cyan box over a random part of the screen rather than allowing me to select or create vertices. This ( https://forum.unity.com/threads/skinning-setting-auto-geometry-is-cutting-my-pixel-sprites.1286408/ ) forum post seems to imply that quad meshes exist as an alternative but I can't find a way to do this. Am I doing something wrong, all I want is to have the geometry properly cover the pixels of the sprite pieces.
which editor version?
Unity 2022.3.4f1, 2D Animation Package 9.0.3, PSD Importer Package 8.0.2
That specific version has a broken skinning editor
Update to newest 2022.3.
People were complaining about that one a lot when it released almost a year ago
alrighty, downloading the editor now, thanks a bunch
Yeah, that version was really troublesome.
If your problem persist try creating a sprite atlas (doen't matter where you allocate it but for organization it could be close to the sprites), where you have to drag your tileset or sprites to the "Objects for Packing" section. Let me now if that solve your problem
When trying to select the tiles in my tilemap, they get selected correctly, but on the grid within tile palette, they're offset and I can't see what I'm clicking. Why is that?
For example it looks like the pond is 4 full tiles and more that are half-filled, but it's actually 9 tiles that fit perfectly
I have my spritemap sliced properly and I can see all the tiles properly, when looking at the tile files individually
Go to the prefab that it's generated when you create the palette. Click on the object named Layer1 and add 0.5 to X and Y of the TileAnchor value of the TileMap component
Or adjust the pivots on the sprite import
Hi guys, idk if this is the right place to post but how do I make images less compressed and blurry? I did the whole "max size" thing and nothing worked.
The images aer 128x128
Have you set Filter Mode to Point and Compression to None?
yo does anyone know what its called when a image can be put side by side with itself and merge seamlessly?
also im pretty sure unity does this by default nowadays but i could be wrong 🙂
Do you mean tiling? Images can tile on X, Y or both axis
why is my spirit so smoll and at bad res?
It looks like maybe is a problem with the camera whe upscale. Also you are looking on the Game view that doesn't work properly until you start the game, check this quick tutorial anyway: https://youtu.be/5jbgT25fc-0?si=pS8IUT-2FCGH0H9p
💡 Create crisp, sharp and perfect pixel art game in Unity 2D.
Tutorial with all the secrets for setting up pixel perfect art: package installation, textures configuration, Cinemachine camera, and more...
🎁 FREE High-quality assets: http://bit.ly/2dhp-free-yt
📚 Read: https://notslot.com/tutorials/2022/09/unity-pixel-perfect
🌍 https://notslot.co...
is there any way to use apply root motion for 2d sprite renderers? I have an animation that makes 2 dashes but i dont know how to make the player to stay where the animation ends
yes but like seamless tiling
basically to create "infinite backgrounds"
guys is it worth investing 200 dollars into a drawing tablet + photoshop when i can already make pixel art in aseprite? what’s the better option and what’s easier
I have a level that inside a box and the box is rotating, the player inside tends to glitch out sometimes and it tends to get him stuck somewhere
Anyone got suggestions how I can fix this?
give us some more context
I will record a video of it when I get home
Hello
otherwise it's okay but when the player is jumping it tends to do this
did you add a tilemap collider 2d
I'm assuming that you mean flipbook animation, since for rigged sprite animation you only need to enable root motion? You'd need to supply a root motion curve yourself for the animation.
How are you rotating it? What are your physics settings?
I have an animation which changes sprites, and the animation moves, but in reality is just the png changing
i want the whole character moving
Right, a flipbook.
You'll have to also animate the position of the root, aside from the png changing.
Alternatively you'd need to add it via code, but at that point you might as well just control the motion via code.
void Update()
{
if(angle == 90)
{
isRotating = false;
angle = 0;
}
if(isRotating)
{
level.transform.RotateAround(centerp.position, Vector3.forward, -1);
background.transform.RotateAround(centerp.position, Vector3.forward, -1);
box.transform.RotateAround(centerp.position, Vector3.forward, -1);
angle++;
}
timer -= Time.deltaTime;
if (timer <= 0)
{
isRotating = true;
timer = 4f;
}
}
You will not have accurate collisions if you're moving any objects with colliders using any Transform methods
is there a better method to do so
Like Spazi said, directly manipulating the transform will break physics.
Any object with a collider that moves must have a rigidbody (kinematic for those that can't be pushed around) and they must move with forces, velocity and torque
Well, either that or don't use physics for the collisions
The alternative is to use your code to detect where collisions and depenetration should happen, rather than unity's methods
Doing that for rotating objects is pretty complicated though
I just started with unity so I don't really know how to do that, any place where I can learn about this?
I suggest rotating using https://docs.unity3d.com/ScriptReference/Rigidbody2D.MoveRotation.html
You'll also want to adjust your settings on the rigidbodies to have them be continuous rather than discrete.
Alternatively, you can make the level geometry be kinematic
Another option would be to not rotate the world at all, and only rotate the camera and gravity.
Which will save you a lot of trouble in many cases
how do I do that
It looks like you're already familiar with rotating objects so rotating the camera probably isn't the issue
Gravity is a vector https://docs.unity3d.com/ScriptReference/Physics-gravity.html
which you could get directly from the camera's negated -Camera.transform.up
Whenever you would have rotated the level, you rotate the camera and in the opposite direction.
And instead of gravity, you can use https://docs.unity3d.com/Manual/class-AreaEffector2D.html as well
I have a question
when I jump on a wall and hold down the right key for example, it keeps me on the wall
how do I prevent that
Also I managed to rotate the camera but the gravity doesn't want to, I will try it again when I get home
That depends on your method of movement
and in an animation how can i use an animationCurve so my animation runs faster in some points and slower in others?
btw if i animate the position of the root the png also moves and its like double moving
Using Navmesh Plus 2D but it doesnt generates for TileMaps even i do exactly same things they say
I think you will have less problems if you use a Composite Collider with your Tilemap Collider, on the image you send looks that you only use Tilemap Collider
Re-open the Unity to let the package integrate itself fully.
fixed it, nvm
not a big artist but i come here to say that there is a program that is def not talked about enough
Pixelorama is freakin awesome i love it sm, really comfortable
i rlly wanted to glaze on it and thought this was the best place to do so
hello, i've created a map for my topdown 2d game but now that im adding things to the environment, i started having trouble with the layers of tiles. anyone know a good way to manage layers so this wouldn't be a problem?
using System.Runtime.CompilerServices;
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
private Rigidbody2D body;
[SerializeField]private float speed;
private bool grounded = true;
private bool facingRight = true;
private bool touchingWall = false;
private Animator anim;
[SerializeField] private LayerMask groundLayer;
private void Awake()
{
body = GetComponent<Rigidbody2D>();
anim = GetComponent<Animator>();
}
private void Update()
{
float horizontalInput = Input.GetAxis("Horizontal");
touchingWall = IsTouchingWall(horizontalInput);
if (!touchingWall)
{
body.velocity = new Vector2(horizontalInput * speed, body.velocity.y);
}
if (horizontalInput > 0.01f && !facingRight)
{
Flip();
}
else if (horizontalInput < -0.01f && facingRight)
{
Flip();
}
if (Input.GetKey(KeyCode.Space) && grounded)
{
body.velocity = new Vector2(body.velocity.x, speed * 1.5f);
grounded = false;
anim.SetTrigger("jump");
}
anim.SetBool("run", horizontalInput != 0);
anim.SetBool("grounded", grounded);
}
private bool IsTouchingWall(float horizontalInput)
{
Vector2 direction = facingRight ? Vector2.right : Vector2.left;
RaycastHit2D hit = Physics2D.Raycast(transform.position, direction, 0.1f, groundLayer);
return hit.collider != null;
}
private void Flip()
{
facingRight = !facingRight;
Vector3 localScale = transform.localScale;
localScale.x *= -1;
transform.localScale = localScale;
}
private void OnCollisionEnter2D(Collision2D collision)
{
if(collision.gameObject.CompareTag("Ground"))
{
grounded = true;
}
}
}
Is this the correct way to check if the player is hitting a wall
I don't want the player be able to walk when it hits the wall
You should be asking in a code channel, but the range of the raycast may be a bit too short. The origin is the pivot, which is often either the center of the object, or the center of the BOTTOM of the object.
.1 may not reach further than the actual collider, thus will never hit.
Try adding Debug.DrawRay to see the direction, position, and length of the ray
Could you help me a bit more with this, I am kind of limited with time currently and need this finished till sunday and it's not so nice of an experience currently
I mean, maybe. What does "help me a bit more" mean, precisely?
Did you do what I said? Is this a different issue?
I am currently working on what you said
well just a couple tips on how to do some things
for example the rotation of the map and stuff
let me just record a video on how it works currently
Some improves I will consider is to use the FixedUpdate instead of the Update for things like movements. Also on IsTouchingWall you have a paremeter (horizontalInput) but it's never used. The result will be something like that: https://hatebin.com/ngompavhdq
Define weird
Well the tiles matched perfectly
somehow I screwed it up
now they look seperated
@solemn latch
I didn't touch the tilemap at all, only added like a canva and now removed it and it stayed this way
I turned off anti aliasing and it looks fine I guess
Color bleed from adjacent tiles, which can be revealed by many causes
Tiles on the tilemap should have padding between them to definitely prevent it
didn't know about that, there is a lot to learn about unity
do you have any suggestions look wise, how can I quickly make the game look more lively
you could add some more colour to it? what is the theme of your game?
medieval
ooh that's a cool theme, I'm getting a dungeon feel from your images. you could add some background decorations like chains or even just some variation in the back wall. that's just what I would do though, so no need to listen
I made the logo for the game as well
I think adding some more traps with somewhat bold colours is another idea. given that your game rotates, I'm not too sure what you will be distinguishing as the floor and the walls but you could also experiment with different tiles
What can I also add for the main menu that's gonna look good
oh sorry
you could enlarge the text, give it an outline, and add a background? that would take a lot of time to make but it would be awesome
do you know where I could download a nice textmesh pro font
do you mean just a font from the internet to upload into Unity? sorry, really new to stuff and not that familiar
if so just look for some royalty free pixel fonts i guess
unless you dont want a pixel font lmao
does this look bad, can't really find a background that fits
the background is ai, and their policy is that it's yours after you generate it
oh cool
anyone here know anything about the line renderer?
A good question! I fell asleep and forgot to delete my question LOL 😦
Hey. When working with the Pixel Perfect Camera in a 2D pixel game, I assign the Reference Resolution, enable the Crop Frame booleans for both axes and keep Stretch Fill disabled.
This way, the frame is cropped on both sides, which results in the black spaces around the game window. Is that what you would usually do in the 2D games, or should Stretch Fill also be enabled?
That is entirely an aesthetic choice, so there is no right answer unless you are trying to match a specific style.
I see, thank you. I'll probably sacrifice quality for resolution then.
Where can I make suggestions for improving a feature in Unity? I noticed a graphical issue with the line renderer that is probably largely unnoticed unless you are trying to overlay two lines with one being the border for the other. It's something very minor, but could probably be fixed quite easily. It has to do with the placement of the corner vertices to be relative to the width.
It would solely be a quality of life suggestion.
Symptoms:
I have some ideas for improvements to help developers get a better workflow.
I have some ideas for improving Unity Services Integration.
I have a feature request.
I have some suggestions...
Idk where to put this so it’s going here. I have a class project where I have to make a 2d game and I’ve downloaded a character from the asset store, but I want to know how I can change the sprite of the guy? I’ve been changing it in photoshop but I’m not sure how to replace the old sprites with this one
Unity will usually update assets automatically if you edit them and then return to unity.
So I just need to save them as the old one?
Or make a copy of the old one and overwrite that, for safety
thank you 😄
Im trying to slice a image in the spirte editor but the slice button is grey out, what do i do? :o?
got, changed tthe Sprite mode to multiple;
I have a 2d animation that has idle, walk left, and walk right. Animator is straight forward, and everything works fine in editor. When I build and test, the idle sprite animation works fine, but others do not render the animation, even though the sprite renderer is updating with the correct frames from the sprite sheet.
First video is in the editor. Works fine. Second video is a build which doesn't display the sprites from the sprite sheet for the other animations.
Do I have to manually include all my sprite sheets in the build?
Can someone help me how to make a GroundCheck ? I don't no how to make it. Tutorials don't work. 😭 😭 😭 😭 😭
wow this is so good
Hi guys i dont get why my Tile Palette is correctly sized but when putting it on my world it became so small
it's the small dark spot on the grass
PPU value of the sprites must match