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 Avanak · Mar 17, 2015 at 03:41 PM · camerascalelinerendererzoomspace

Keep line renderer width same on screen no matter camera distance

So I am displaying a solar system in a scene. The star is in the middle and planets at different distances around it. I have a line renderer component on each planet that creates a circular line around the star to the distance of the planets. I have the line width set so that it looks right when I am zoomed in to the planet. However when I zoom out to view the whole system, the lines are too thin and seem jagged.

Does anyone know a trick to scale the line renderer's width equally to the camera's distance?

Comment
Add comment · Show 1
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 AlwaysSunny · Mar 17, 2015 at 03:12 PM 0
Share

I assume you really do mean "line renderer" when you say "line renderer" - I'm not sure you could do this with a trail renderer.

I don't think there's an "easy" mathematical trick, unless your camera movements are going to be very limited. You might consider scaling the width based on the camera's distance from the scene origin (the sun?). Depending on how your camera can move, this may satisfy the request.

 scale = $$anonymous$$athf.Lerp($$anonymous$$, max, distanceBetweenCameraAndOrigin / maximumDistanceConsidered);


To achieve truly perspective-independent width, you'll need to programmatically create your lines from multiple dynamically-billboarded quad segments and size them in a way that respects each vertex's position in screen space. This is not something I've ever had to do, but I've done some work in the general area; it's not for the faint of heart. ;)

1 Reply

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

Answer by Avanak · Mar 18, 2015 at 02:57 PM

Thank you very much AlwaysSunny!

It turned out that this simple script worked just fine:

 Vector3.Distance(planetPosition, cameraPosition) / 1000;

Still thanks for the input.

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 echl · May 16, 2016 at 10:50 PM 1
Share

How did you use the above line of code?

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Change UI scale in relation to 3D camera 0 Answers

Is there a way to zoom GUI and scene at the same time? 0 Answers

Stop main camera from zooming 2D 1 Answer

Accurate Pinch Zoom 1 Answer

Need help with 2D orthographic camera zooming 2 Answers


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