Giter Club home page Giter Club logo

Comments (9)

JamesMcMahon avatar JamesMcMahon commented on May 11, 2024 1

Ah, yup that is totally it. I thought translating 0.01 to 0.032 made sense because I was unsure of how you arrived at 0.01 in the first place. But 1/32 gives me a value of 0.03125, which scales quite nicely.

Thanks so much for you help, I had obviously been staring at this too long today as you can tell by me poking around the code. 😄

At the very least this issue will hopefully allow people to Google the correct Tiled2Unity vertex scale for a 32x32 tile.

from tiled2unity.

JamesMcMahon avatar JamesMcMahon commented on May 11, 2024

I also looked at the source code to see if I could find the source of the "drift".

public static Vector3D PointFToUnityVector(PointF pt)
{
    // Unity's coordinate sytem has y-up positive, y-down negative
    // Apply scaling
    PointF scaled = pt;
    scaled.X *= Program.Scale;
    scaled.Y *= Program.Scale;

    // Have to watch for negative zero, ffs
    return new Vector3D(scaled.X, scaled.Y == 0 ? 0 : -scaled.Y, 0.0f);
}

Could the conversion from a float to a double here be responsible? When 0.032f is converted to a double it would result in 0.0320000015199184 (see http://csharppad.com/gist/5cf382820ae0d538233d). That is such a minor difference that I am not sure if it would have an affect, but it was one thing that stood out at me after briefly looking at the source.

from tiled2unity.

Seanba avatar Seanba commented on May 11, 2024

Hi James, I'm away from my desk but shouldn't the scale factor be 1/32 instead of 32/100?

1/32 == 0.3125, a very nice number to represent in floating point.

Best,
Sean

Sent from my iPhone

On Aug 26, 2015, at 3:52 PM, James F McMahon [email protected] wrote:

I'm attempting to export a tiled map made up of 32x32 tiles to a Unity so that I get 1 tile == 1 unit. I'm using a vertex scale of 0.032 and am running into some trouble. The scale of the map appears to "drift" and misalign with Unity's scale.

Here is what my tiled map looks like for reference, this is a 16x16 map made up of 32x32 tiles:

And here is the imported map (some of the mesh renderers on the more colorful layer are turned off):

If you look closely, the scale of each tile doesn't appear to be consistent. So while it appears to be mostly aligned in the upper left (note the grid lines):

By the time you get to the upper right, the grid lines no longer match:

I am fairly new to Unity and just started using Tiled2Unity the other day so there is a chance that my vertex scale is just off but it seems like based on your article the proper scale for 32x32 should be 0.032.

Any help is welcome.


Reply to this email directly or view it on GitHub.

from tiled2unity.

TitoOliveira avatar TitoOliveira commented on May 11, 2024

Hi guys, i was searching for a similar issue and google led me here.
Have you managed to solve your problems? I have a 16px tileset and seems like it is not possible to have float values with more than two decimals places on Tiled. How did you manage to scale your map by 0.03125 when importing it to unity?

from tiled2unity.

JamesMcMahon avatar JamesMcMahon commented on May 11, 2024

So it's been a long time since I looked at any of this stuff but I believe it should be 1/16 or 0.0625 for a 16px tileset.

from tiled2unity.

TitoOliveira avatar TitoOliveira commented on May 11, 2024

Yeah. My issue is that when setting a custom property in tiled, i either have to live with 0.06, or 0.07.
I know this is a Tiled issue and not a Tiled2Unity, but i wanted to know if you guys managed to circumvent this limitation.

from tiled2unity.

JamesMcMahon avatar JamesMcMahon commented on May 11, 2024

Oh I don't know. I don't remember there be a decimal place limitation. Maybe that was something that was introduced in the year since this issue was created.

Might be worth starting a new issue if you are running into trouble.

from tiled2unity.

Seanba avatar Seanba commented on May 11, 2024

If you guys are entering this value into Tiled2Unity then take note that I've changed Vertex Scale to "Pixels Per Unit". This way you enter the same value as you do in Unity for your Sprites.

image

I made this change to be consistent with Unity, especially since I was getting a lot of support emails on the subject. Keep it simple, you know?

from tiled2unity.

TitoOliveira avatar TitoOliveira commented on May 11, 2024

Thanks for the reply. I'll check this soon

from tiled2unity.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.