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 pepeshka · Sep 01, 2012 at 07:50 PM · camerarotationparenting

Parenting camera to object but keeping rotation?

Hi,

I'm having trouble with changing parents at run-time. I have an object that is rotating slowly and when the camera approaches the object, I make the camera a child of the object. I do this because I want it's rotation and position to follow the object's movements. I would use a script to just update the camera's position, but the camera is user-controlled and I want the user to be able to move around the object after being parented.

At the moment I parent the camera, though, it's rotation snaps to match that of the object. I don't want that behavior - I want the camera to have the same global rotation that it had before being parented.

I'm thinking right after I parent the camera I have to figure out the difference of it's pre and post parenting rotation and set it to that, but I can't figure out what methods to call on the camera - I'm a bit new to local/world space issues.

Any help is much appreciated!

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

1 Reply

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

Answer by Fattie · Sep 01, 2012 at 08:07 PM

fortunately it's easy!

in game engines you constantly have empty objects, that are either wrappers or markers.

example, say you have an "enemy". you might have a wrapper for sliding motion, and a wrapper for rotational motion, and yet another one for something else, and so on.

in short make a new empty object and call it SuperThing. Now sit your current object inside that, we'll call it Thing.

now all your rotation and so on, do that on Thing, nothing will change. (just change all your current connections carefully)

now . parent the camera NOT TO "Thing", but rather to SuperThing.

this is the heart of game engines, everything is ridiculously easy - you'll be amazed how simple. Hope it helps

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 pepeshka · Sep 01, 2012 at 09:28 PM 0
Share

Hm, well i do want the camera to rotate with Thing - if they were siblings, it wouldnt inherit the rotation motion, right?

avatar image pepeshka · Sep 04, 2012 at 08:27 PM 0
Share

I played around with this and found that it works how I want if I parent the camera under a wrapper object and change the parent of the wrapper object. Thanks for the tip!

avatar image Fattie · Sep 05, 2012 at 04:53 AM 0
Share

magnificent !

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

8 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

1st person Camera rotates suddenly in another direction when unparenting from a platform 1 Answer

Camera 360 not following parent 2 Answers

Transform Rotation - Maths Problem 2 Answers

Irregular position when instantiating clone during camera rotation? 1 Answer

How do I have a Child tell a Parent to move without the Child itself moving 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