Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

How do I set the world's size?

Discussion in 'Getting Started' started by SomeJDude, Mar 11, 2015.

  1. SomeJDude

    SomeJDude

    Joined:
    Feb 13, 2015
    Posts:
    10
    I started a new 2D project and added a single sprite. I would like the world's position values to correspond to pixel size. Meaning, if I have a 25x25 pixel sprite, and tell it to move to
    Code (CSharp):
    1. new Vector(transform.position.x, transform.position.y + 25, 0)
    then the sprite will move down the distance of its own height. Currently, the sprite instead moves way past the camera.

    What can I do to set things up this way?
     
  2. Effervescent

    Effervescent

    Joined:
    Mar 7, 2015
    Posts:
    31
    I think it's because when you add 25 to the y position you're actually adding 25 unity units, which is much greater than 25 pixels.

    One solution I can think of is go to bring up the Inspector window for your sprite and change "Pixle to Unit" to 1 (I think it's 100 by default). By the same token, I suppose moving your character by 0.25 also works!

    This is probably not the best solution and I'm not sure how camera mode and/or distance affect this, I hope someone more experienced will comment on it!
     
  3. SomeJDude

    SomeJDude

    Joined:
    Feb 13, 2015
    Posts:
    10
    "Pixle to Unit"? I don't see anything like that in the Inspector.
     
  4. Effervescent

    Effervescent

    Joined:
    Mar 7, 2015
    Posts:
    31
    You have to have the sprite selected:




    Like I said before, though, this is probably not the best solution and hopefully someone would comment on the pros and cons of doing this! o:
     
  5. SomeJDude

    SomeJDude

    Joined:
    Feb 13, 2015
    Posts:
    10
    Oh, so when you said sprite, you mean the actual image. I was looking at the GameObject.