Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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
0
Question by Gray · May 13, 2011 at 10:10 PM · cameraviewportorthographicaspect-ratio

Ortho camera viewport setup?

Everything I've found on this seems either way more complicated than what I am looking for, or specifically for a scrolling/moving camera, which also isn't what I need.

I am trying to set up a plane and camera. I want the viewport of the camera to give me a 960x640 view.

Right now I have a plane GameObject set up like this: Pos: 480, 0, 320 Rot: 0, 0, 0 Scale: 96, 0, 64

and a MainCamera set up like this: Pos: 480, 320, 320 Rot: 90, 0, 0 Scale: 1, 1, 1 Projection: Orthographic Size: 572 Normalized View Port Rect: X=0, Y=0, W=1, H=1

What I would like to have is a view of the plane, with the camera rendering a 960x640 view. I'd like to be able to place objects in this view at a 1:1 pixel ratio. It would be great if I could have it set up so that if I instantiate an object, I can place it at a position using the viewport's screen coordinates (I'd prefer bottom left being (0,0), but anything logical would work, really.

What settings should I be looking at to set the plane object and the camera object up to do this?

Many thanks in advance (and if anyone has pointers to any basic tutorials on things similar to this, I'd love to see them).

--Gray

Comment
Add comment
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

3 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by DaveA · May 13, 2011 at 10:42 PM

This may help somewhat: http://unity3d.com/support/documentation/ScriptReference/Camera.ViewportToScreenPoint.html

also http://unity3d.com/support/documentation/ScriptReference/Camera-orthographicSize.html

Comment
Add comment · Share
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
0
Best Answer

Answer by Bunny83 · May 14, 2011 at 12:45 AM

Well, the orthographic camera's aspect ratio is adjusted by the actual resolution. I'm a bit confused, do you want to work on the x-z-plane or why does your camera looks "downwards"? ... Anyway, just follow these steps:

  1. Set your project resolution to 960x640 in the project settings.
  2. Set your camera's orthographicSize to 320 (half height)
  3. If you want to work on the x-z-plane with the origin (0,y,0) at the bottom left just move your camera and your plane to 480,y,320
  4. Make sure the plane have a lower y value than the camera.
  5. Actually that's it. In the editor you should select the project resolution (affects the aspect ratio) in the drop-down-field at the top left of your game-view.

If you set it up that way x==0 z==0 is at the bottom left of the screen and x==960 z==640 is at the top right.

ps. The plane (unity default plane) is set up like you've done above but y-scale = 1. localScale == 96, 1, 64 (don't set a scale to 0 if it doesn't matter keep the 1 ;))

You could also parent your camera to the plane, that way the camera sits at 0,dist,0 where dist is the distance from your plane which should be positive.

Comment
Add comment · Show 1 · Share
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 Gray · May 16, 2011 at 10:07 PM 0
Share

See below for more detail, not enough room in Comments to do so... --Gray

avatar image
0
Best Answer

Answer by Gray · May 16, 2011 at 10:19 PM

As for why the camera looks "downwards"... I'm really new to this, and ...well... it just ended up that way, heh. I'm not married to that, but it seems kind of a pain to change everything.

I went back and fiddled about, using your advice above, and even went so far as to create a brand new scene, with a camera, lightsource, and newly-created plane. I have a simple script attached to the plane that when you click on the plane, it uses Debug.Log to spit out the coords that you clicked on.

Using this, what seems to be happening both in the new scene, and in the old scene is that while I would expect clicking in the bottom left of the screen would generate something like (0, 0, 0), while clicking on the top right would produce (960, 640, 0). What I am actually seeing is that the bottom left does give (0, 0, 0), but the top right is giving (1116.0, 744.5, 0). And I really am at my wits end to figure out why.

I also have some "tiles" that are placed in the scene. These tiles are simply Cube GameObjects, Scaled (100, 1, 100) with a 100x100 texture on them. The idea is to build a set of these on the right side, the user clicks one, then clicks somewhere in the viewport and if there isn't already a tile there, it moves it there. I can place them along the right side fine, but they all seem to be 115x115 now, which I am sure is another symptom of whatever I am seeing/not understanding, above.

--Gray

Comment
Add comment · Show 2 · Share
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 Bunny83 · May 16, 2011 at 10:29 PM 0
Share

I can't reproduce that. I get exactly what you would expect. Are you sure that you set your project resolution to 960x640 and set the gameview resolution to the project resolution? If you hve done this you gameview should have black bars top/bottom or left/right to make sure the resolution matches the one you've configured. If you just set an aspect-ratio the gameview's size will be different. I've also created a cube and tested the border coordinates. everything is fine... Btw. you can edit your question if you want to change/add information ;)

avatar image Gray · May 17, 2011 at 01:00 AM 0
Share

Thank you so much, that was the problem. I didn't realize there was a separate setting for the Game view. Setting it to Standalone (960x640) makes it work exactly like I wanted it to. Again, thank you very much, this has been frustrating me for over a week.

--Gray

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

No one has followed this question yet.

Related Questions

How does the aspect ratio work? 0 Answers

Center Object in Viewport 1 Answer

Prevent objects from disappearing when zooming in on an orthographic scene? 1 Answer

How to get a camera to render to render texture at a custom aspect ratio. 1 Answer

Why Is My Orthographic Camera Not Rendering at the Full Resolution? 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