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

Same size in view Independent from distance

Discussion in 'Scripting' started by raycord, May 24, 2019.

  1. raycord

    raycord

    Joined:
    May 15, 2019
    Posts:
    4
    Dear all,

    I want to scale an object so that it has every time the same visible size in the view of the main camera, independent from the distance to the camera. My problem is, that I don't know the size of the object. I know the scale factor, but not the real size. I played with the bounding box, but I can't solve the problem. The visible size is just varying.

    Maybe You know a simple way to keep the visible size of an object in the view constant regardless of the distance to the camera.

    Thank You very much,
    Ray
     
  2. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    1,905
    I am assuming you're using a perspective view.

    Remember the original scale and distance of the object when it's the perfect size.

    Any time after that, you can adjust the scale proportional to the current distance. If the distance doubles, the scale should double to maintain the same camera-apparent size.
     
  3. raycord

    raycord

    Joined:
    May 15, 2019
    Posts:
    4
    Sure, You're right, and I'm a fool. :oops: Thank You very much.
     
  4. nithisha08

    nithisha08

    Joined:
    May 19, 2022
    Posts:
    3
    How do you find the distance of the object when it is the perfect size?
     
    Sam_PaB likes this.