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 Blizzard_jedi · Jun 03, 2013 at 06:03 PM · animatormecanimragdoll

Switching Animator on/off

Hi everybody! I have a character, controlled by mechanim animator+script. I'd like to have an opportunity to switch animator off and then to switch it on. The first issue is easy, but I haven't managed to implement the second one yet. I tried just to set the 'enabled' property to 'true' from the script. I also tried to make an animation state with an empty mask. But all these things don't work properly. The animator remains disabled.

By the way, I need this to switch between a pure ragdoll and an animation-controlled character. So I thought about making some kind of a switcher: ragdoll on - animator off / ragdoll off - animator on.

Thanks beforehand for help.

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 Tarlius · Jun 03, 2013 at 06:05 PM 0
Share

Welcome!

From your somewhat vague description of the problem, I'm thinking you're trying to turn it back on from inside Update or something, which doesn't run when you disable a GameObject/script.

If thats not the case, it would be helpful if you provide code.

avatar image Blizzard_jedi · Jun 03, 2013 at 06:25 PM 0
Share

Sorry for the bad description.

I have two methods inside the animation controller class: $$anonymous$$ill() and Resurrect(). The first one simply searches for all the children's colliders and rigidbodies (the ragsoll structure) and switches them on like that:

 collider.isTrigger = false;
 body.is$$anonymous$$inematic = false;


It also switches off the animator and the character controller:

         _animator.enabled = false;
         GetComponent <CharacterController> ().enabled = false;


At last, it sets the 'bool _disabled' variable of the animation controller script to 'true', but doesn't disable the script, actually. Resurrect() makes precisely the opposite things.

And here is the 'Update' method:

     void Update ()
     {    
         if (Input.Get$$anonymous$$eyDown ($$anonymous$$eyCode.$$anonymous$$) && _disabled)
             Resurrect ();
         
         if (RPGCamera._instance.enabled && !_disabled)
         {
             HandlePlayerInput ();    
             CalculateAnimatorParameters ();
             
             if (_needAlign)
                 AlignTorsoToCamera ();
         }
     }

Inside 'HandlePlayerInput' we find:

     private void HandlePlayerInput ()
     {
         if (Input.Get$$anonymous$$eyDown ($$anonymous$$eyCode.$$anonymous$$))
             $$anonymous$$ill ();

It seems to be correct. At least, the script remains enabled. By the way, I also tried to implement the 'Resurrect()' method in another script - this made no difference.

P.S. In the question nearby I've seen guys using the following construction:

 animator.enabled = !activeRagdoll ;


I wonder, if it works correct...

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

15 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

Related Questions

how to stop animator? 4 Answers

Animator overriding collisions? 0 Answers

Blending Animator Animations with Ragdoll 2 Answers

Using Ragdoll on character with mecanim animator 2 Answers

Mecanim and Ragdoll Issues? 2 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