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 /
avatar image
1
Question by Sagstad · Dec 10, 2017 at 08:46 PM · animationfbxanimator controllerhumanoidlocalscale

Issues with rig animation when flipping local scale.x direction on game object

I am creating a 2D game and the enemies in the game have rigid body 2D connected to them. I have not worked on the game for almost a year and when I started coding again I was forced to update Unity to the latest version (because I had upgraded iOS on my Mac).

An unexpected bug appeared. When I change direction of my enemies through a script the animation/animator changes its y position. I suspect changing localScale.x with -1 also affects the position of the animation/animator.

Correct: alt text
Wrong: alt text
The enemies in my game are flipping when OnCollisionEnter2D is called.

     Vector3 enemyScale = transform.localScale;
     enemyScale.x *= -1;
     transform.localScale = enemyScale;


It's only when enemyScale.x == -1 that the animation/animators Y-position is off. As soon as OnCollisionEnter2D is called a second time and the enemy returns to it's original localScale the animation/animator jumps back to it's correct Y-position.

Anybody else who have encountered this problem?

UPDATE
It's seems like the root position of the Animator is changing. Still not closer any solution. Any help would be grateful.

wrong.jpg (45.3 kB)
corret.jpg (43.3 kB)
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

2 Replies

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

Answer by Sagstad · Dec 16, 2017 at 11:32 AM

I solved my problem by changing the rig animation type from Humanoid to Generic.

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 jdean300 · Dec 11, 2017 at 10:02 PM

You may be able to work around this by changing your object hierarchy around. I'm guessing you have something like this:

Root Object (w/ animator, collider, and collision response script) ---arm ---leg ---body ---....

Try changing it to:

Root Object (w/ collider and collision response script) --- base (w/ animator) ------ arm ------ leg ------ body ------ ...


This way the object the animator is on doesn't change when the scale changes. I've fixed many strange problems like this by moving all rendering/animating to children objects.

Comment
Add comment · Show 1 · 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 Sagstad · Dec 12, 2017 at 06:37 AM 0
Share

Thank you for your reply.

I actually have the hierarchy you refer to.

 Root Object (w/ collider and collision response script)
 --- base (w/ animator)
 ------ arm
 ------ leg
 ------ body
 ------ ...

That's why I find this behavior so strange.

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

71 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

Related Questions

Copyng animation from one model to another that have 100% matching rigs? 0 Answers

Retargetting Quality low on SAME RIG 0 Answers

Mechanim, Unity 5.2.1. Odd retargeting errors. 1 Answer

FBX Exporter imcomplete anim exports in 2018.2.20 0 Answers

(Animation) Bones' transforms are gone 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