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 /
This question was closed Aug 26, 2013 at 02:00 PM by Fattie for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by Zylann · Aug 26, 2013 at 10:45 AM · camerarotationgameobjectvector3quaternions

Rotate object instead of camera around it?

How to rotate an object as if it was seen by another camera?

I have a GameObject and a main camera seeing it from (0, 0, -1). I positionned several cameras (views) around the object to configure different views of it, but for design reasons*, I can't move the main camera (the others are just useful for their preview in edit mode). In addition, I don't know at advance the initial rotation of the model, then I may use only delta rotations. So how do I rotate the object as if it was seen from the other cameras?

I've tried this :

     private void RotateModel(Transform fromView, Transform toView)
     {
         // Rotate the object by using a delta angle from the current point of view to the next
         
         // Calculate delta
         Vector3 vecFrom = (fromView.localPosition - model.localPosition).normalized;
         Vector3 vecTo = (toView.localPosition - model.localPosition).normalized;
         Quaternion delta = Quaternion.FromToRotation(-vecFrom, -vecTo);
         
         // Rotate the object
         Quaternion newModelRotation = model.localRotation * delta;        
         HOTween.To(model, 1.25f, new TweenParms().Prop("localRotation", newModelRotation));
         //model.localRotation = newModelRotation;
     }


But I always get wrong results... I tried not to negate the vectors, change their order, calculate delta with Quaternions instead but no success... it's like I missed something but don't know what. Any ideas?

  • could rotate the camera around anyway, but in my game I would have to create a new layer for each object, that would waste a lot of them as there is lots of objects to watch...

Comment
Add comment · Show 3
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 Fattie · Aug 26, 2013 at 12:13 PM 0
Share

This is totally, completely wrong - heh!

You'll be very pleased to know it's actually super-easy to do this.

Just use

http://docs.unity3d.com/Documentation/ScriptReference/Transform.Rotate.html

Footnote, "RotateAround" is often very useful, too ... http://docs.unity3d.com/Documentation/ScriptReference/Transform.RotateAround.html

avatar image Zylann · Aug 26, 2013 at 01:28 PM 0
Share

I know these functions, but the problem isn't just how to rotate an object, but doing it the way it behaves as a Google-earth-like view : I could place a pivot on its center, place the camera as child of it and rotate the pivot to orbit around. However, I'm trying to achieve the same behaviour, but without moving the camera, and rotating the object ins$$anonymous$$d.

Finally, I used the first option and reduced the far plane of each camera so they don't see each others...

avatar image Fattie · Aug 26, 2013 at 01:59 PM 0
Share

post comments as comments, not answers

0 Replies

  • Sort: 

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

Using the accelerometer to rotate Camera 1 Answer

Player rotation = Camera Rotation 0 Answers

Rotate a gameobject like car tire 2 Answers

Workaround for Quaternion.eulerAngles 360 Degree Limit? 1 Answer

How to change object direction when Camera Rotates 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