• 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 BLOODLORD · Mar 28, 2013 at 02:41 AM · ragdoll

Ragdoll freezes? HELP??!

Hi guys! I am making a zombie fps game. So far, there's nothing wrong, except that the ragdoll occationally freezes in it's animation pose when i kill the zombie, unless the player does a goomba stomp. How do I solve this?

I use Unity version 3.5.6, and mixamo's free zombie model.

Heres the ragdoll, health and animation scripts:

Health:

 using UnityEngine;
 using System.Collections;
 
 public class Health : MonoBehaviour 
 {
     [SerializeField]
     int _maximumHealth = 100;
         
     int _currentHealth = 0;
         
     
     override public string ToString()
     {
         return _currentHealth + "/" + _maximumHealth;
     }
     
     public bool IsDead { get{ return _currentHealth <= 0; } }
     
     PlayerStats _playerStats;
     EnemySpawnManager _enemySpawnManager;
     
     void Start () 
     {
         _currentHealth = _maximumHealth;
         
         GameObject player = GameObject.FindGameObjectWithTag("Player");
         _playerStats = player.GetComponent<PlayerStats>();
     }
     
     public void Damage(int damageValue)
     {
         
         _currentHealth -= damageValue;
         
         if (_currentHealth < 0)
         {
             _currentHealth = 0;
         }
         
         if (_currentHealth == 0)
         {
             if(tag == "Player"){
                 Destroy(GetComponentInChildren<NightVision>());
                 Destroy(GetComponentInChildren<MuzzleFlash>());
                 Destroy(GetComponentInChildren<MuzzleLight>());
                 Destroy(GetComponentInChildren<GunBang>());            
                 Destroy(GetComponent<CharacterMotor>());
                 Destroy(GetComponent<FPSInputController>());
                 Destroy(GetComponent<MouseLook>());
                 Destroy(GetComponent<RifleWeapon>());
                 Destroy(GetComponent<PlayerGui>());
                 Destroy(GetComponent<CharacterController>());
                 
             }else{
                 GameObject spawner = GameObject.FindGameObjectWithTag("Spawner");
                 _enemySpawnManager = spawner.GetComponent<EnemySpawnManager>();
                 
                 _enemySpawnManager._maxZombies--;
                 _playerStats.ZombiesKilled++;
                 Animation a = GetComponentInChildren<Animation>();
                 a.Stop();
                 Destroy(GetComponent<EnemyMovement>());
                 Destroy(GetComponent<BossAnimation>());
                 Destroy(GetComponent<CharacterController>());
                 Destroy(GetComponentInChildren<EnemyAttack>());
             }
 
             Ragdoll r = GetComponent<Ragdoll>();
 
             
             
                         
             if (r != null)
             {
                 r.OnDeath();
             }
         }
     }
 }


Ragdoll:

 using UnityEngine;
 using System.Collections;
 
 public class Ragdoll : MonoBehaviour {
 
     void Start () 
     {
         DisableRagdoll();    
     }
     
     void DisableRagdoll()
     {
         Rigidbody[] allRigidbodies = GetComponentsInChildren<Rigidbody>();
         
         foreach (Rigidbody r in allRigidbodies)
         {
             r.isKinematic = true;
         }
     }
     
     void EnableRagdoll()
     {
         Rigidbody[] allRigidbodies = GetComponentsInChildren<Rigidbody>();
         
         foreach (Rigidbody r in allRigidbodies)
         {
             r.isKinematic = false;
         }
     }
         
     public void OnDeath()
     {
         EnableRagdoll();
     }
         
 }

Animation:

 using UnityEngine;
 using System.Collections;
 
 public class EnemyAnimation : MonoBehaviour 
 {
     Animation _animation;
     
     void Start () 
     {
         _animation = GetComponentInChildren<Animation>();
         
         string animationToPlay = "";
         switch (Random.Range(0, 3))
         {
         default:
         case 0:
             animationToPlay = "Move1";
             break;
                 
         case 1:
             animationToPlay = "Move2";
             break;
             
         case 2:
             animationToPlay = "Move3";
             break;
         }
         
         _animation[animationToPlay].wrapMode = WrapMode.Loop;
         
         _animation.Play(animationToPlay);
         _animation[animationToPlay].normalizedTime = Random.value;
     
     }
     
     void Update () {
     
     }
 }


Any help would be greatly appreaciated!

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 sahilushaikh6 · Feb 08, 2020 at 06:50 PM

I'm suffering from the same problem , I guess your ragdoll collider is not activated and animation controller in not disable

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

11 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

Related Questions

Add force on Instantiated Ragdoll 1 Answer

how i make a enemy stop his animation one frame before he dies 0 Answers

How to set an "hard" ragdoll 0 Answers

Adding force to ragdoll after isKinematic is disabled? 1 Answer

Character pick up Ragdoll 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