Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    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.