Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 11 Next capture
2021 2022 2023
1 capture
11 Jun 22 - 11 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 Hedonsoft · Jul 28, 2015 at 12:52 AM · cameratransformvector3camera rotateparent transform

Why is my Camera rotation tilted after parenting it to head?

When I parent my Camera to my player's head is rotated sideways 90 degrees and tilted 90 degrees. In my Start() I'm parenting it to the head then setting the position and rotation to that of the head. It might be gard to see on the photo but the camera is pointing sideways instead of straight ahead of her and it's rotate so instead of orbiting up and down it looks left and right but thet axes is set right and the camera pans fine when it's not parented. alt text

    void Start()
     {
         fpsCam = GameObject.Find("FPSCam").GetComponent<Camera>();
         head = GameObject.Find("Head");
         fpsCam.transform.parent = head.transform;
         fpsCam.transform.localPosition = Vector3.zero;
         fpsCam.transform.localRotation = head.transform.rotation;
     }
 
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 Positive7 · Jul 28, 2015 at 01:26 AM 0
Share

You can set it in Inspector to the right position. No need the script I$$anonymous$$O.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Rhylvin2015 · Jul 28, 2015 at 01:36 AM

If you still wanna use the script I suggest not using

 fpsCam.transform.localRotation = head.transform.rotation;

your head is probably rotated if its not i suggest using

   fpsCam.transform.localRotation = head.Quaternion.identity;





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 Hedonsoft · Jul 28, 2015 at 02:17 AM 0
Share

head is a GameObject and GO's don't have a definition for Quaternion. I have to assign the Camera in code because I'm generating the character at runtime.

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

23 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

Related Questions

nullifying targetObject after a Smooth LookAt Transition 2 Answers

UI objects move at different speeds on different resolutions 1 Answer

Move camera when mouse is near the edges of the screen 1 Answer

Return camera to original rotation values Logic 1 Answer

Tracking Vertical Angle between Camera and Object 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