Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 jakejolli · Jun 16, 2016 at 03:50 PM · camerarotation3d

Model Viewer Camera Rotation

I've been working in Unity for quite a while, and I hate asking simple questions like this, but quaternions still baffle me.

I need to make a CameraController with rotation functionality. The camera will have focus on different objects at various points, and I need the ability to rotate around the object (left, right, up and down).

Right now, this is what I have:

  public void RotateRight() {
         transform.RotateAround(focusObject.transform.position, Vector3.down, rotationSpeed * Time.deltaTime);
     }
 
     public void RotateLeft() {
         transform.RotateAround(focusObject.transform.position, Vector3.up, rotationSpeed * Time.deltaTime);
     }
 
     public void RotateUp() {
         transform.RotateAround(focusObject.transform.position, Vector3.right, rotationSpeed * Time.deltaTime);
     }
 
     public void RotateDown() {
         transform.RotateAround(focusObject.transform.position, Vector3.left, rotationSpeed * Time.deltaTime);
     }

Ultimately, these functions will be called by UI interactions (thus their segregation).

The Up/Down and Left/Right work just fine, so long as their not used together. As soon as I start combining rotations (or rotating Up/Down after Left/Right, etc), everything falls apart so to speak.

I'm not sure how to explain how I want this to function, so better to just show an example: https://sketchfab.com/models/08d80ef4bc2d4ab3a57b5b3ff227856d

This is easy to do if I rotate the OBJECT, and not the camera, but that is not an option for me.

In a nutshell, how would I go about duplicating the rotation functionality of the sketchfab viewer?

Comment
Add comment · Show 4
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 aybeone · Jun 16, 2016 at 11:54 PM 1
Share

You're looking for an orbital camera: http://mentalogicus.blogspot.fr/2012/02/comment-faire-une-camera-orbitale-en.html

avatar image jakejolli aybeone · Jun 17, 2016 at 12:31 AM 0
Share

Looks promising, thanks! Hopefully Google's translate is good enough to maintain the technical accuracy of the article.

I'll have a deeper look at it tomorrow.

avatar image jakejolli aybeone · Jun 17, 2016 at 05:36 PM 0
Share

If you want to convert this to an answer, I'll gladly accept it. After some tweaking for my own scene, the provided tutorial was great! Thanks again

avatar image aybeone · Jun 17, 2016 at 07:42 PM 1
Share

Don't bother, glad it helped you out :D

0 Replies

· Add your reply
  • Sort: 

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

62 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 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 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

Rotation of player based on camera direction and joystick direction in 3D world 1 Answer

Rotate camera only in 2 directions based on player touch 1 Answer

Mouse axes based on position, not movement. 1 Answer

player rotate to camera direction but not moving in it's direction 0 Answers

How to set the player in front of the camera in any rotation 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