Hello Guest

Author Topic: First time using 2D Toolkit, questions, thoughts and suggestions  (Read 8940 times)

ryf9059

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 41
    • View Profile
I'm new to Unity and just get my hands on 2D Toolkit trying to make a 2.5D game.

Generally, it is good, but I do have few questions that I can't figure out.

First, for the pixel-perfect rendering, I can't quite figure the ortho distance regarding different window size, what I did is by simply clicking 1:1 button at the sprite inspector. Problem is, as I said I'm going to make a 2.5D game (says, actually 3D but with 2D textures and different distance) and will have different resolution. And I want the game to handle this just like 3D games: bigger window size, more view area, and vice versa, but the texture size don't change itself.

As I know the placement by the pixel perfect function depends on the screen size: I need to specifically set it up in the setting target height, my screen resolution is 1920x1080 and 1080 works perfect, but if I want to test it says on 1080x720 window do I need to change the target high to 720 instead? I tried it but the texture become bigger and blurier and not suit my needs.

Second, I don't understand the padding size in setting, what does it mean? I understand padding in CSS context where it's the area "inside" the texture (from border to innerside with some size) but I don't see a point of having padding here. From the padding.

Third, the BIGGEST PROBLEM, I have problem snapping the sprite (holding control or control/shift same time while draging in translation mode), it leaves a HUGE gap between those two collidars. Yesterday, somehow, if I have a sprite then dupe it and snap it, the first one will work correctly, but the second one comes with the gap, and today for some reason even that will not work and the gap becomes bigger, I don't know what I did but I didn't mess with the collider. I will attach screenshots.

EDIT: I tried the default sprite that comes with example which doesn't have collidars, not working too (the quad didn't snap).

Lastly, I found that if I create a sprite with collider attached, and change the size of the collider, even remove it, and then dupe it, the collidar will re-appear and the size will change back.

The third and fourth problem don't happen with other objects such as cube and sphere.


Please provide workaround and fix for the problem, especially for snapping, it affect my entire level generation.

Thanks
« Last Edit: April 09, 2013, 06:41:02 pm by ryf9059 »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: First time using 2D Toolkit, questions, thoughts and suggestions
« Reply #1 on: April 10, 2013, 01:35:19 am »
First, for the pixel-perfect rendering, I can't quite figure the ortho distance regarding different window size, what I did is by simply clicking 1:1 button at the sprite inspector. Problem is, as I said I'm going to make a 2.5D game (says, actually 3D but with 2D textures and different distance) and will have different resolution. And I want the game to handle this just like 3D games: bigger window size, more view area, and vice versa, but the texture size don't change itself.

As I know the placement by the pixel perfect function depends on the screen size: I need to specifically set it up in the setting target height, my screen resolution is 1920x1080 and 1080 works perfect, but if I want to test it says on 1080x720 window do I need to change the target high to 720 instead? I tried it but the texture become bigger and blurier and not suit my needs.

You will need to change your camera parameters to make it display more information at a higher resolution. This depends on what kind of camera you're using, etc. If you're using a perspective camera, you should move it back appropriately to reveal more data based on the resolution ratio.

Second, I don't understand the padding size in setting, what does it mean? I understand padding in CSS context where it's the area "inside" the texture (from border to innerside with some size) but I don't see a point of having padding here. From the padding.

Padding in graphics & textures usually refers to how many pixels are added around the edge of the UV islands.
http://wiki.polycount.com/EdgePadding
It doesn't really relate to CSS padding in any way.

Third, the BIGGEST PROBLEM, I have problem snapping the sprite (holding control or control/shift same time while draging in translation mode), it leaves a HUGE gap between those two collidars. Yesterday, somehow, if I have a sprite then dupe it and snap it, the first one will work correctly, but the second one comes with the gap, and today for some reason even that will not work and the gap becomes bigger, I don't know what I did but I didn't mess with the collider. I will attach screenshots.

EDIT: I tried the default sprite that comes with example which doesn't have collidars, not working too (the quad didn't snap).

I didn't even know that feature existed until now. I can see how it will be really useful for positioning trees on terrain, etc, but I can't see much use in positing sprites.

Surface snapping seems to position the object based on the local 0, 0, 0 position though - from what I can tell, if you have 2 cubes and select one and ctrl + shift drag it to the second, it will interesect with it, but the origin of the cube, the center, will be placed on the surface of cube 2. This makes it not so useful with sprites, where the origin could be anywhere depending on how its set up. If it were at the base, then perhaps this could work... As the Unity docs says, this only works when objects have colliders. Also it messes up with the z value, making it not so useful for positing flat 2d sprites.

Are you using snapping (ctrl / command and arrow)? the Units for this are fixed, which might explain the gap you're seeing. I can't see the positions on there, but if they are regular then that will explain it. It won't happen with a cube or sphere because the default size of the cube/sphere is 2 units, and the default snap is 1 unit. ie. they will align perfectly.

Lastly, I found that if I create a sprite with collider attached, and change the size of the collider, even remove it, and then dupe it, the collidar will re-appear and the size will change back.

If you want to modify the colliders manually after the sprite has been created, you should set it to User Defined in the sprite collection editor. You can then tweak it any way you like and 2D Toolkit won't reset it. Otherwise 2D Toolkit will rebuild it every time the game starts / level is loaded, etc.


ryf9059

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 41
    • View Profile
Re: First time using 2D Toolkit, questions, thoughts and suggestions
« Reply #2 on: April 10, 2013, 04:25:29 am »
I didn't even know that feature existed until now. I can see how it will be really useful for positioning trees on terrain, etc, but I can't see much use in positing sprites.

Surface snapping seems to position the object based on the local 0, 0, 0 position though - from what I can tell, if you have 2 cubes and select one and ctrl + shift drag it to the second, it will interesect with it, but the origin of the cube, the center, will be placed on the surface of cube 2. This makes it not so useful with sprites, where the origin could be anywhere depending on how its set up. If it were at the base, then perhaps this could work... As the Unity docs says, this only works when objects have colliders. Also it messes up with the z value, making it not so useful for positing flat 2d sprites.

Are you using snapping (ctrl / command and arrow)? the Units for this are fixed, which might explain the gap you're seeing. I can't see the positions on there, but if they are regular then that will explain it. It won't happen with a cube or sphere because the default size of the cube/sphere is 2 units, and the default snap is 1 unit. ie. they will align perfectly.


Thanks for the reply!

I use the sprite as tile and snap the tile to make ground, platform, etc and yes I'm using snapping (ctrl / command and arrow)
I'm not sure about how to set the origin since they all default at the center of the texture and I see no option for setting origin, and I'm not quite sure about the base and regular you are mentioning. All I want is to have two collidars align perfectly, they all have the same Z value

I saw this in a video posted in unity forums, start at 00:18, where you drag the tile and place it adjacent to each other

http://www.youtube.com/watch?feature=player_embedded&v=xWK7VmgsC9M

I want to achieve that effect, but with collidar since sprites are going to land on it. Do you have a way to achieve this like I said or the video above? If not will you consider implementing a feature that snap\align adjacent sprites?
« Last Edit: April 10, 2013, 05:41:55 am by ryf9059 »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: First time using 2D Toolkit, questions, thoughts and suggestions
« Reply #3 on: April 10, 2013, 01:50:32 pm »
The video posted there uses vertex snap. While that won't snap to the collider, it will to the sprite vertices themselves.
http://docs.unity3d.com/Documentation/Manual/PositioningGameObjects.html <- search for vertex snapping.

If your sprite shape matches the collider, that might be enough...