• 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 Foestar · Jun 19, 2017 at 11:20 PM · rotationquaternionvariablesanglefloat

Bone Rotation on X (or any) axis Issues

Okay, so I'm trying to make my characters spine rotate based off the rotation of the camera. I've had no luck so far and have done plenty of googling and managed to work around a bit, but still to no luck. First things first. I found that you can't seem to rotate the bones of the character unless done in a late update. So I tried a basic code like so and it worked.

 public Transform Spine;
     void LateUpdate()
                 {
                     Spine.transform.Rotate(30, 0, 0);
                 }

The character looks up at a slight angle as intended. Great! Now to make it based off the camera's rotation so the character will actually be looking up when the player does. So I made a float. Actually I started with Quaternions but had issues with it. SO I decided to make it as simple as possible. I created the float SpineX, then tried to base the rotation the exact same way but using the float instead of 30. So like so:

     public Transform Spine;
     public Transform CameraControlObject;
     public float SpineX;
         void LateUpdate()
                     {
                         Spine.transform.Rotate(SpineX, 0, 0);
                     }
     void Update()
     {
         SpineX = CameraControlObject.transform.rotation.x;
     }

So I thought this would work, but it doesn't rotate him at all. And when I did something similar using Quaternions, Vector3, etc. I had similar luck where it wouldn't rotate properly. But at least it rotated. I am gonna try and rewrite it back into my Vector3 format and play with that because at least that way it did rotate. Maybe I can correct it.

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 Cherno · Jun 20, 2017 at 02:20 AM 0
Share

Have you tried a different Space parameter (relativeTo)?

Transform.Rotate

1 Reply

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

Answer by Foestar · Jun 23, 2017 at 10:22 PM

This has been solved. I used the following:

 Spine.transform.rotation = CameraControlObject.transform.rotation;

And noticed my bones were off on the orientation. So to solve it I placed an empty object that aligned with my bones so I didn't have to deal with exporting/rigging orientation within a 3D modeling program. Then I placed the camera inside of that and made sure it was set properly.

Comment
Add comment · 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

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

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

How can I multiply the rotation of a mirrored object? 1 Answer

How can I angle an image along an line renderer and maintain a look-at-camera rotation? 0 Answers

Object makes random jumps in rotation 1 Answer

how to convert the angle to roatation? 1 Answer

How do I clamp the Z-Axis Rotation for this code? 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