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
0
Question by Anglerteam Games · Mar 25, 2014 at 10:21 PM · cameracamera.screentoworld

How to update ScreenToWorldPoint before Camera renders?

Let's say I'm trying to temporarily change a camera's position/rotation or projection matrix so that within the same frame I can use ScreenToWorldPoint to calculate things based on the temporary changes to the Camera. I want to later revert these changes (again, in the same frame) before rendering. These results would then be used over, say, the next second to accomplish my task.

However, it seems that things are not updated until the Camera renders. I've tried using .CopyTo to create a new Camera and get the information from there, but that doesn't work. Nor do ResetWorldToCameraMatrix or ResetProjectionMatrix. Can anyone offer any insight?

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Patel-Sagar · Mar 26, 2014 at 12:09 PM

I tried one thing...

my camera is at (0,0,0) and one cube is at (0,0,5). so distance between two should be 5.

Now in LateUpdate() I changed camera position to (0,0,1). NOTE: LateUpdate() is called after Camera.Render(). then in OnPreRender() I print distance between cube and camera.after that I changed camera position back to (0,0,0).

Result: distance in output is 4. but in scene rendering camera is always stays at (0,0,0).

In Short: in LateUpdate() : Do changes into Camera Do anything between this. in OnPreRender() : revert changes into Camera

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 Anglerteam Games · Mar 26, 2014 at 04:27 PM 0
Share

Thanks -- this was helpful in figuring out the ordering. I managed to fix my problem by changing what I was trying to do.

avatar image Patel-Sagar · Mar 27, 2014 at 05:08 AM 0
Share

please mark answer as correct and vote up if you are satisfied with my answer.

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

21 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

All Sprites Instantiate In top right of screen for some reason. 0 Answers

How to make camera position relative to a specific target. 1 Answer

Terraria-esque 'scope' function? (2D) 1 Answer

Pause Button Brings down a menu options! help needed! 2 Answers

Simple Camera Movement?! (javascript) 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