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
0
Question by MOrlando · May 18, 2012 at 04:48 PM · animationanimationsanimation-blending

Animation Shifting

Hello,

I've got an enemy character with dozens of animations. Many of these animations (especially since they're mo-capped), shift the enemy mesh off of the origin. I have a base game object with my AI scripts and character controller attached, under which the rig and skinned mesh reside.

The problem: When the enemy plays an animation that shifts him off of his local origin, such as my transitional animation from idle to an alert state (he sort of stumbles backwards startled), I need a clean way to recalibrate the base object so the next time I play an animation, it's relative to the new direction.

Here's a better example: The enemy is aiming at the player. The player strafes around the enemy, forcing the enemy to play a "90 degree turn animation". If the player continues to strafe, the enemy will play that animation again (to face the player who is now behind what the enemy's original orientation was) however the animation will play from his original forward, ending up facing the same direction (90 degrees right or left).

My attempted code fix:

 // Recalibrate Base
 // .,;,.,;,.,;,.,;,.,;,.,;,.,;,.,;,.,;,.,;,.,;,.,;,.,;,.,;,.,;,.,;,.,;,.,;,.,;,.,;,,;,.,;,.,;,.,;,
 void RecalibrateBase()
 {
     Vector3 RootPos = m_RigRoot.transform.position;
     Quaternion RootRot = m_RigRoot.transform.rotation;
     
     Vector3 RigForward = m_RigRoot.transform.forward;
     RigForward.y = 0.0f;
     
     transform.position = RootPos - ( Vector3.up * m_RigRootOffset );
     transform.rotation = Quaternion.LookRotation( RigForward );
     
     m_RigRoot.transform.position = RootPos;
     m_RigRoot.transform.rotation = RootRot;
 }


Unfortunately, when I call that function after I determine the transitional animation has completed (all I do is check m_Animation.IsPlaying( m_TransitionalAnimation ) to see if it's done), the enemy pops a bit...each subsequent call sends the enemy further and further into the ground like quicksand. Funny, sure...but not helpful. :)

Sorry for the unnecessarily long post...the main question is, has anyone encountered this kind of problem or, more importantly, know of a better way to handle recalibrating a base object that has an animated mesh below it whose direction/position is crucial?

Thanks for the help! -Matt

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
0

Answer by MOrlando · May 18, 2012 at 08:24 PM

I think I figured out what's wrong. The child bone (the rig root) that I'm trying to manually offset based on the parent's new position is likely getting moved by the animation.

In other words I say "parent go here", "now child move in the opposite direction so that you're still in the same world position". Then the animation comes along and overrides the bone's position based on the animation playing.

That's my assumption, I'll test it now and see. :)

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.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Animation in World Space 3 Answers

How to run 1 animation, then other 2 Answers

How can I change my AnimatorState instantly? 1 Answer

Invalid Layer Index? 1 Answer

Animation Running Game 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