TL;DR: Video explanation here http://youtu.be/WJZ6_TOdu3A
Hi All,
I am currently in the process of developing a PoC for a Zombie game. I have a zombie model who is rigged/animated, and I’ve made a Ragdoll for him as well. The Rigidbody components got attached on all of the proper places. When I turn “isKinematic” on and animation off, the zombie falls to the ground as I wanted him to.
The reason I am doing this is to avoid a die animation (which wasn’t included with the model). The goal is that, when the zombies die, they’ll simply go limp and fly away with the force of the bullet (obvs not very far, but I do want to see some Zombie carnage).
Here is the script that I am using to accomplish this at the moment:
using UnityEngine;
using System.Collections;
public class Zombie : RTSUnit {
public float kill_after = 5;
private float kill_counter = 0;
private bool dead = false;
private Rigidbody[] rigidBodies;
// Use this for initialization
void Start () {
rigidBodies = GetComponentsInChildren<Rigidbody>();
foreach(Rigidbody r in rigidBodies) {
r.isKinematic = true;
}
}
// Update is called once per frame
void Update () {
if(kill_counter > kill_after !dead) {
Debug.Log("STARTING AT " + System.DateTime.Now);
dead = true;
for(int i=0; i<rigidBodies.Length; i++) {
rigidBodies[i].isKinematic = false;
rigidBodies[i].useGravity = true;
}
Debug.Log("FINISHED AT " + System.DateTime.Now);
} else if(!dead) {
kill_counter += Time.deltaTime;
}
}
}