How to deal with extended sprite edges?

I know the question is really badly worded, but I had no idea what else to say, to make it short.

So here’s a fairly detailed explanation of what I’m talking about:

Basically what my game is going to be composed of, is square terrain sprites, and since it’s mostly going to be earthly type terrain like dirt, grass, etc. Most need to have some sort of bits sticking out for the edge sprites, so it doesn’t just look like perfect squares.

So let’s say I just have a wall. That wall can’t be perfectly flat since it’s made of dirt, and dirt naturally falls apart, so it’s going to have like a few extra pixels to each outer edge for the corresponding sprite, which will just be random curvy lines and stuff.

The problem I’ve run into, while testing the ones (terrain sprites) that I already made, is that if there are fully square sprites, and the edge sprites are on top, I can’t align them properly while holding “V” (which I use to snap them together).

I’ve attached a picture to show what I’m talking about.

As you can see (if you looked at the picture), when I try to snap them together, it just snaps the very edge of the sprite, instead of its centre bottom section, so what I have to do is change the x axis manually until it’s on the centre.

My question is, how would I get around this? I need to have these edge bits on my sprites to add realism, but how would I make them, so that this doesn’t happen? btw I already tried editing the sprite in the Sprite Editor, so that the edge bits are cut off.

I did consider making the edge bits their own sprites, and attaching those wherever I need them, but it seems like too much of a hassle.

Any ideas? :confused:

Well, have the sprites be bigger than they need to be to fill a cell, and just center it properly (when slicing sprites unity will auto center, but if your proportions are off this won’t be the ideal center).

Then you can treat them like they are for instance, 32x32 in size and position them on a grid with those rules, but in fact the sprite is visibly larger than that, and “overhangs” into the next “cell” of the grid.

That might be what you meant your already trying to do, but anyway I’d not have them be separate sprites for the overhangs, but rather just use clever layer changing to make sure the appropriate sprites are on top through code.

That way all you’ve got to worry about is things like deciding “top of surface grass” vrs “buried under other blocks dirt” and other types of blocks… and then your code will just auto arrange based on the location of the particular cell and it’s neighbors.

If you made this very robust, you could just save levels as like text files with info of what type of cell is what, and load an appropriate sprite then set an appropriate depth to the sprite to keep the proper stuff visible. You’ll need many sprites for different angles and connections between the “cells”. Use games like “Terraria” for inspiration in this department.

I don’t think you understood my question. I’m not talking about stuff like the overhang texture being in front of the grass (which is what I assume you’re talking about, after reading your reply). What I’m talking about, is the fact that because some sprites have overhangs, they are wider.

So let’s say I have a 50x50 sprite, which is the centre sprite, with nothing but the base dirt texture. The overhangs have extra pixels on either the sides or bottom/top, so they are something like 56x50, or 49x54. Depending on which outside part we’re talking about (aka top-left corner, left side, right-bottom corner, etc.).

Therefore since the one in the screenshot is 56x50, as it has 3 extra pixels on either side, it doesn’t align with the rest when I try to snap it using “V”.

What the screenshot depicts, is me snapping the bottom-left corner of the sprite with overhangs, to the top-left corner of the base sprite. And as a result of it having more width in pixels, it shoves the whole sprite to the right slightly, therefore not allowing the two sprites to align unless I set the x axis manually.

What I was asking is, is there any way of bypassing this, so it doesn’t take into account the overhangs of the first sprite. Or if there is a work-around.

I’m not worried if the textures overlap at this stage.
Here’s an updated version of the screenshot.
http://imgur.com/a/suXGc

Ohhh right got you, so your asking about snapping :stuck_out_tongue:

Sorry I misread your post, I thought you were meaning how to arrange them and setup the sorting order :X

Give me a moment to reread and think if there is anything I can contribute or not, and I’ll edit this post to add something useful.

EDIT: Ok so if I press V while I have a cube (16 units x scale) selected, it tries to select different vertices at the angle of the camera sort of deal, and doesn’t do snapping quite right for me. I’m using win 7 if that makes a difference but I use the ctrl key to do snapping, and it lets me take an object and move it by X amount that I define in the snap settings (EDIT > SNAP SETTINGS) where I can set it to 16 units snap, and if I hold control and move the “arrow thingies” it will snap to the right place like this:

Have you messed with those? Do you hold V then grab the corner and… uhh? what? I don’t use that snapping system much so sorry to be less help than I meant to be!

Anyway, if I set it to a position like 32 x and 32 y in the world through the inspector, then hold ctrl, then drag the arrows to move it somewhere, it snaps properly right next to the other cube.

So in theory even if the cube was say, 18 units scale (a larger sprite or whatever) then it should still arrive at the same snapping position if I do it that way… is that similar to what you do?

I don’t use that at all, and never actually heard of the “Snap settings”. I literally just hold V while clicking and dragging objects, and it snaps to the edges of other objects. I’m using Windows 10, and the latest beta version of Unity (5.5.0b11).

The problem isn’t with the actual object, but with the graphic. The problem is that since the overhangs are a part of the same game object, it aligns the very edge of that object, even when there’s nothing there.

The overhangs are meant to be sticking out slightly from both sides, but since Unity doesn’t understand the human thought process, it just snaps the edges of the entire sprite file. Therefore I end up with one overhang being aligned with the edge of the below tile, and the rest of the snapped tile being pushed to the right.

This would be simple to fix, if only it was possible to snap the outer midpoints of objects by holding V, and not just the very edges.

EDIT: Just found out the way I’m doing it is called “Vertex snapping”.