Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by nullpainter · May 27, 2017 at 02:26 PM · animation2d animationroot motion

Root Motion prevents transform in animation from running

I have two layers in my Unity 2D animation; the base layer is an endless loop animating the object's sprite, and the other layer contains an animation which modifies the object's transform when the player lands on it.

This trivial animation - involving a single transform - isn't working when I enable root motion on the animator.

This animation is run by the following on the object:

 void OnCollisionEnter2D(Collision2D other) 
 {
     animator.Play("Bounce", bounceLayerIndex, 0f);
 }

The player has an associated OnCollisionEnter2D() which makes it a child of the object.

This animation is trivial, containing a keyframe with transform (0,0) and another with transform (0,-0.3f). The idea is that when the player lands on the object, the object responds slightly.

My difficulty here is with root motion. When I don't have root motion applied, everything works fine - except I need to have the object inside an arbitrary parent since I'm applying a transform in the animation. The parent is positioned where I want the object to be, and the object is positioned at (0,0) relative to it.

I found this approach a bit klunky, particularly since there are going to many of these objects, all at different positions in 2D space. I therefore looked into root motion, which appears to be suitable for this use case. I checked the 'Apply root motion' checkbox on the animator on the object and clicked the 'Generate Root Motion' curves on my animation.

The animator indicates that the animation is running as expected when the player collides, however the transform is having no effect.

Interestingly, when I moved the animation to the base layer (and disabled the endless sprite animation), the transform animation does run correctly - but I then get an odd endless loop of OnCollisionExit2D()/OnCollisionEnter2D() as the object moves. The player is a child of the object at this point, so this behaviour is unexpected.

I'm clearly misunderstanding how root motion is supposed to work. I assumed that if my object was at (0, 1f) then with root motion applied, my animation transform of (0, -0.3f) would animate the object to (0, 0.7f) - namely, relatively to the object's position.

I'm using Unity 5.6.0f3 personal.

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 nullpainter · May 25, 2017 at 09:42 AM 0
Share

FWIW, I added a non-Transform property to the animation (a sprite renderer X flip, just for something quick) and this did get animated correctly. Just no position, or rotation for that matter.

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

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

Physics with generic root motion 0 Answers

Why does my character animation freeze the first time it load each frame of the animation for the first time ?,Why does my character freeze while playing his animation for first time ? 0 Answers

Why is my sprite moving during animation? 0 Answers

2D sprite transitioning, keeping keeping in-flow with 'idle' animation 0 Answers

Player teleports when animation finishes 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