• 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 deSpeach · Jul 21, 2014 at 09:53 PM · rotation axis

Rotate Camera 180 degrees around a plane

Hey guys,

I wanted to make a script which allows the player to see the whole plane... I don't really know how to explain my problem, so I made an image: alt text

The script should calculate the rotation of the Camera and the position. (The Camera should be ~50 units away from the center of the plate)

best regards deSpeach :)

planebla.png (13.3 kB)
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 Graham-Dunnett ♦♦ · Jul 21, 2014 at 09:53 PM 0
Share

None of this makes any sense to me...

2 Replies

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

Answer by robertbu · Jul 21, 2014 at 10:35 PM

Script on the camera with 'plane' being a reference to a Unity plane:

 transform.position = plane.position + plane.up * 50.0;
 Transform.LookAt (plane);

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 deSpeach · Jul 22, 2014 at 12:37 PM 0
Share

Thanks man that worked :)

avatar image
0
Wiki

Answer by calebheale · Jul 21, 2014 at 10:43 PM

Based on your images it looks like what you want is to make your camera orthogonal to the plate at the center position. Here is how you can do that:

What you need to do is get the normal vector to the plane that plate is on, so you can move in that direction from the center of the plate 50 units.

you need 3 points on that plane, I would recommend using three vertices from your plate object itself (I'm assuming you know how to find those). You can get the normal from them by creating a Plane object and this value will be calculated for you. Then you just need to multiply that value by a scalar (in your case 50) and add it to where you want to start (the center of your plate object).

pseudocode:

 a, b, c // Vector3 objects containing coordinates of 3 vertices.
 Plane myPlane = new Plane(a, b, c);
 cameraPosition = plate.center + 50 * myPlane.normal;

I'm not sure how unity calculates the normal based on the 3 points given so you might need to actually subtract the 50 * myPlane.normal to get the proper result. I'm also assuming you know how to set the rotation.

Here is some additional reading in case you want to better understand this process

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 deSpeach · Jul 22, 2014 at 12:38 PM 0
Share

Thanks for the deep explanation :) The code of the guy above worked but I'll keep this one in $$anonymous$$d ;)

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Shuriken Particle System GetParticles() not working 1 Answer

Rigidbody Turning 2 Answers

Split quaternion into multiple angle-axis rotations for hierarchical ordered appliance 3 Answers

Recreating the rotation sphere in-game? 0 Answers

Having trouble rotating a turret 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