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 Lachee1 · Jul 16, 2013 at 01:37 AM · anglecircletangent

Make Camera Angle Equal Circle Tangent

In my game I am currently working on there is several planets on which the player can land on (they have gravity that sucks players up too). Once the player has entered the gravity of the planet, I would like the camera angle to equal that of the tangent created by the circle (planet, its 2D), however I cannot get my head around how to do it and I have tried several formulae and other equations with no pervail.

How would I set the angle (z-axis off the camera) to equal the tangent?

Here is a quick diagrams to show my predicament (wanting feta angle to make camera's) and please not that the X axis is opposite to conventional means: alt text

Thanks in advance, Lachee

planet.png (374.6 kB)
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

2 Replies

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

Answer by menneske · Jul 16, 2013 at 08:53 AM

You want the camera to rotate so that the player on the planet looks like he is standing straight up?

Use the camera transforms LookAt, and use the direction from the planet to the player as the WorldUp parameter.

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 Lachee1 · Jul 16, 2013 at 11:55 PM 0
Share

Thankyou so much! In my camera controller I found the direction, made the camera look at it with the direction as up and the 0'ed out the x,y rotations and it worked, perfectly!

I thought I was over thinking it :|

avatar image
0

Answer by robertbu · Jul 16, 2013 at 02:06 AM

The easiest way is to use Vector3.Cross(). Unity is a 3D environment, so in order to generate the tangent, you need two pieces of information. The first is the vector between the center of the circle and the player (which you outline in your drawing). The second is the vector of the axis of the circle.

If your circle is really a sphere, there are an infinite number of tangents, so you need one other vector that is different than circle/player vector in order to get the tangent. Without more description, it is hard to advise you on this second vector.

Comment
Add comment · Show 3 · 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 Lachee1 · Jul 16, 2013 at 03:26 AM 0
Share

This has unfortunately confused me more. Is it possible you can show some sample code so I can get a better hold on what you are trying to explain? How do I use Vector3.Cross to produce the angle I am looking for?

avatar image robertbu · Jul 16, 2013 at 08:44 AM 0
Share

Vector3.Cross() is the way you get a tangent, but in rereading your question, I'm unclear about what angle you are trying to apply to the camera, and it is unclear that you need to calculate the tangent at all to solve your problem.

  • Is this object a sphere or a circle?

  • Does the camera look down the 'Z' world axis, or the camera look at the object from arbitrary views?

  • What are you trying to align with the tangent line? The transform.up of the camera? The transform.right of the camera?

With answers to these, I can write you a bit of script.

avatar image Lachee1 · Jul 16, 2013 at 11:56 PM 0
Share

Thank you for your help, but menneske has given me the solution.

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

16 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

Related Questions

How can I set all of my animation keyframes tangents to become right angles? 2 Answers

Draw only part of a circle 0 Answers

Get Vertices of Circle Facing Any Direction 1 Answer

Making a Turret Have a Circle Sector Range 1 Answer

Find tangent points on circle 0 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