Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by trothmaster · Sep 21, 2012 at 05:14 AM · resolutionaspect ratioviewporttoworldpoint

ViewportToWorldPoint different resolutions

I am trying to display an object on the screen using an orthographic camera. The camera size is set to 100. I want the object to appear in the same area of the screen regardless of aspect ratio or resolution.

If I set my resolution to 854x480 the objects ViewPortToWorldPoint is .5719438 and displays where I want it.

If I then set the resolution to 1024x600 and set the objects position to the same ViewportToWorldPoint, it does not appear in the viewport at the same relative position. I thought that was the point of ViewportToWorldPoint?

I used this to set the position:

   var p : Vector3 = cam.ViewportToWorldPoint (Vector3 (.57194,0,0));
     transform.position = Vector3(p.x, transform.position.y, transform.position.z);


alt text you can see the correct placement here:

alt text and this is at 1024 width but with the same ViewportToWorldPoint position of .57194 it is now cut off on the left.

Is this the wrong approach for this? The size and scale work great, I just need the object to be in the right area of the screen depending on the resolution width. Thanks!

1.jpg (57.2 kB)
2.jpg (48.3 kB)
Comment
Add comment · Show 11
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image whydoidoit · Sep 21, 2012 at 04:01 PM 0
Share

I notice that in your ViewportToWorldPoint call you aren't specifying a Z coordinate - I can't quite get my head around that with an orthographic camera but might that be causing you a problem? You aren't then positioning your graphic at the z you called ViewportToWorldPoint on.

Just a thought - might be totally irrelevant.

avatar image trothmaster · Sep 21, 2012 at 04:06 PM 0
Share

Thanks for the reply! Unfortunately even if I do supply a z coordinate it has the exact same results...like this:

var p : Vector3 = cam.ViewportToWorldPoint (Vector3 (.57194,2.645176,19.80699));

transform.position = Vector3(p.x, p.y, p.z);

avatar image whydoidoit · Sep 21, 2012 at 04:08 PM 0
Share

One further random thought - the screenshots make the graphics look a different size - is this the case on the higher resolution? It it the size of the graphic and the change in aspect ratio that is causing the effect?

avatar image trothmaster · Sep 21, 2012 at 04:21 PM 0
Share

they are the same exact size, the only thing that changes is what is visible, my screenshots were hastily taken so they look like a different size. Thank you for your replies!!

avatar image trothmaster · Sep 21, 2012 at 05:17 PM 0
Share

Just thought i'd add some info: If the aspect ratio is 16x9 everything is fine. When I switch aspect ratios I want to change the position of this object automatically but I don't know the equation that would be needed to do such a thing. I thought that ViewportToWorldPoint was what I needed but I guess its not?

Show more comments

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

10 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Scaling particles across different aspect ratios 0 Answers

Cinemachine confiner on different aspect ratios 1 Answer

Outside game clear screen 0 Answers

Fixed aspect ratio; window position 1 Answer

No "Target Resolution" options? / Force Aspect Ratio? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges