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 Pat · Jan 18, 2011 at 05:27 AM · rotationquaternionslerpbone

Slerp with rotations from different spaces

I'm trying to create a character controller for the iphone that will rotate the upper body of a character. It works by taking the input from a touch joystick, creates a vector that's effectively in world space and then uses the rotation of that vector to rotate a bone in the character. Unfortunately the local space of the bone is very different than world space. So it doesn't rotate correctly. Here's the code that I'm using...

function CharacterRotation()
{       
    if (combatJoystick.position != Vector2.zero)
    {
        rotationAmount = (minRotationSpeed + maxRotationSpeed * combatJoystick.position.magnitude) * Time.deltaTime;
        aimVector = Vector3 (combatJoystick.position.x, 0, combatJoystick.position.y);
        aimRotation = Quaternion.LookRotation(aimVector, Vector3.up);
        bone.transform.rotation = Quaternion.Slerp(bone.transform.rotation,  aimRotation, rotationAmount ); 
        print ("Rotation happening");       
    }
}

If I add a null object to the character with a local space similar to world everything works great except it breaks all the animations :-(

The models I'm using are prefabs so fixing it bones isn't really an option for me, moreover, I'd like to generically solve the problem so that it's easy for me to reuse the controller with other purchased models.

Any idea how I can get this to work right?

Thanks!

PS, I know the head look controller can do something like this, but that's overkill for what I'm trying to do and the unity asset store says it's not supported on the iPhone, which is an issue for me since my target platform is the iPhone/iPad.

Note: updated code for clarity (changed focus to bone).

Comment
Add comment · Show 2
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 cjmarsh · Jan 18, 2011 at 06:30 AM 0
Share

What is the focus.transform.rotation referring to?

avatar image Pat · Jan 18, 2011 at 04:53 PM 0
Share

Sorry,that's a typo. Focus and bone are the same thing. I was trying to clarify my code for the question. I've updated for clarity.

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

No one has followed this question yet.

Related Questions

Slerp to make the right/left side face another object 2 Answers

How to reset a game object to its original rotation. 1 Answer

Rotation of an object with quaternion 1 Answer

Quaternion.Slerp and Quaternion.Euler problem 1 Answer

Changing rotation of Quaternion 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