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 19, 2012 at 04:37 PM · animationanimationsworldspaceanimation-blending

Animation in World Space

Hi folks, I've got a common issue with what appears to be a hidden solution. I've got a game with tons of finished mo-cap animations for our characters and enemies. Many of these animations (transitional animations mostly...aka, the animations that play from one loop to another like idle to aggressive) shift the actual character off of the origin.

So when I play, for instance, the character's idle animation and then play the transition from idle to aggressive, he shifts off of the origin a bit (rotations, of course, end at arbitrary values also). If I then followed with an aggressive idle animation (gun up), he'll pop back to the local origin of the blank object above the rig in the hierarchy and animate from there. I obviously need to avoid that.

The only way I really see this being feasible is to have a root game object that the rest of the hierarchy is a child of. That game object sits between the characters feet and moves with him within the animation but is always on that floor plane between his feet (or, depending on the animation, an equivalent location). When one of these transitional animations is done, I take that root and zero him out so his position/orientation is 0,0,0.

The next time an animation plays (for instance the aggressive idle), the rest of the rig would still be correct relative to the parent, and the parent (being this floor plane root) will now start (first frame of that animation has the root at the origin of the scene) at the correct position, avoiding any popping.

I can only do this once that transitional animation has finished so I know the this floor plane root won't get animated off the center, thus causing a pop in the animation.

Does all of this make sense? My characters' animations move/rotate them in world space and when I play the next animation, I need them "back at the origin" so it plays correctly relative to their new location/orientation.

Any help would be immensely appreciated, I don't have a ton of time on this one. :) -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

3 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Paulius-Liekis · May 22, 2012 at 07:27 PM

People usually make "in-place" animation to solve this problem.

Comment
Add comment · Show 2 · 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 Bunny83 · May 22, 2012 at 08:11 PM 0
Share

Yes, the problem is that Unity can't handle motion delta automatically. Animation-curves are always absolute values within it's localspace.

In our project we also animated our character in-place and the characters movement code actually moves the root / parent. However i guess it should be possible to "extract" the motiondelta by using LateUpdate, read the offset of the inner model (which comes from the animation), move the inner object back to 0,0,0 and finally apply this offset accumulative to the parent object which makes the character move. In theory this should work, but i don't have tested it yet since our char doesn't have motion delta. Unfortunately I'm a programmer so i can't make my own model / animations ;)

avatar image Paulius-Liekis · May 23, 2012 at 05:48 AM 0
Share

Problem with your given solution is that you will be unable to blend animations.

You can also write an AssetPostprocessor and remove animation curves from your root node after import.

avatar image
0

Answer by MOrlando · May 23, 2012 at 12:01 AM

Thanks Paulius, I thought I mentioned that we've been given hundreds of mo-capped animations. We don't really have the option to remake the animations, heh.

I do think we've got a potential solution on the horizon. It looks as though we were able to add a node that moves with our characters hips but sits on the floor between his feet. When an animation ends, I'll zero that node out (the rest of the rig is a child of this node) after moving the base node to that location. Then I'll play the next animation which should start with that node zero'd out, so there shouldn't be any hiccups in animation or anything.

We'll 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
avatar image
0

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

So we were able to implement world transforms/rotations with all of the mocap data we were given using a root node that tracked the global movement. I do, however, have a slightly unrelated problem...

Right now I determine if the enemy needs to go to a certain state (and therefore a certain animation) and so I call his transitional animation to get there. For instance, the enemy needs to go to an Alert State from his Idle state so I call the IdleToAlertIdle animation. I then have the following code inside an update (hardcoded the animation for ease of testing):

 if( !m_Animator.IsPlaying( m_TransitionalAnimation ) )
 {
     m_TransitionalAnimation = null;
     
     RecalibrateBase();
     m_Animator.CrossFade( "ENY_M_Stand_CBR_AlertIdle" );
 }



So the above code works fine. The RecalibrateBase() function handles moving my nodes around so if the transitional animation moved the mesh off of the origin, it's fixed. The problem is the cross-fading. Since technically there's no animation playing since the transitional animation finished, the enemy pops to the new alert idle. There's nothing to actually blend from.

Do I need to add a transitional animation for each of these scenarios? Is there a way to tell the enemy to blend to the new animation without needing an active animation? The enemy still remains in the final frame's bone positions since no animations are playing, he doesn't pop to a T-Pose. I literally just want him to blend from that final pose (from the just finished and no longer active transitional animation) to the new animation.

If anyone can help, that'd be fantastic. I tried CrossFade(), Blend(), and I tried setting the transitional animation's wrapmode to 'ClampForever' but the crossfade of the enemy blends between the new idle and the old animation (which still has the offset root so he blends from the wrong position/orientation).

Thanks for the help! -Matt

Comment
Add comment · Show 2 · 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 Paulius-Liekis · May 25, 2012 at 07:26 AM 0
Share

First of all: you shouldn't post comments as answers or questions as answers, that just confuses poeple who are trying to solve same problem later.

Look into clamp$$anonymous$$odes. You probably want to set wrap$$anonymous$$ode=ClampForever on your first animation, so it will keep sampling last frame and then you'll be able to do a simple crossfade to next animation.

Welcome to Unity Asnwers!

avatar image MOrlando · May 25, 2012 at 09:16 PM 0
Share

I apologize, I noticed afterward that I posted in the wrong location.

Anyway, as I mentioned in the post above, I did try ClampForever. The problem is that with the world animation, the last frame that's forever clamped is moved off the origin, while the new animation I'm playing needs to be centered at the origin. CrossFading between those 2 blends very incorrectly.

I think the solution right now is to have a 2 frame animation that is set to ClampForever that I play after the transitional animation that matches that animation but is zero'd out so the blending works ok.

Thanks for the posts, I appreciate the help.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Animation Shifting 1 Answer

Do animation rotations refuse to accept negative values? 2 Answers

Animation not looping 1 Answer

Create animation transitions via script. 0 Answers

The 'correct' way to deal with animations in a grid-based game? 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