// Use this for initialization void Start() { ragdoll = GetComponent <CharacterRagdoll>(); //gets the ragdoll script cc = GetComponent <CharacterController>(); // gets the character controller component enemyAnim = GetComponent <Animator>(); //gets the animator movement = GetComponent <EnemyMovement>(); //gets the enemy movement script //enemyControl = GetComponent<CharacterController>(); // gets the .... ragdoll.OnRagdoll += OnRagdoll; //connects to a delegate }
//private void OnControllerColliderHit(ControllerColliderHit hit) //{ // Debug.Log(hit.controller.gameObject.name + " hit"); // CharacterRagdoll ragdoll = hit.controller.gameObject.GetComponent<CharacterRagdoll>(); // objects = GetComponent<GrabbedObject>(); // // if we collide with a ragdoll // if (ragdoll != null) // { // if (objects.isAttachable) //not entering // { // if (hit.gameObject.layer != 27) // { // AttachObject(ragdoll, hit.point, hit.normal); // } // } // } // add a joint to ourselves and connect it to the ragdoll's hips private void AttachObject(CharacterRagdoll ragdoll, Vector3 point, Vector3 normal) { Debug.Log("KILL " + ragdoll.gameObject.name); // add a fixed joint FixedJoint joint = gameObject.AddComponent <FixedJoint>(); //joint.autoConfigureConnectedAnchor = false; Rigidbody rb = ragdoll.hips.GetComponent <Rigidbody>(); //Debug.Log("HIT: X: " + point.x + " Y: " + point.y + " Z: " + point.z); BoxCollider col = ragdoll.hips.GetComponent <BoxCollider>(); ragdoll.hips.position = point; //Move hips to the point you want them attached to joint.connectedBody = rb; //joint.connectedAnchor = new Vector3(ragdoll.hips.position.x, 1, ragdoll.hips.position.z); List <Rigidbody> rbs = ragdoll.GetRigidbodies(); foreach (Rigidbody rigiB in rbs) { rigiB.isKinematic = true; } ragdoll.transform.parent = transform; }
// Use this for initialization void Start() { ragdoll = GetComponent <CharacterRagdoll>(); ragdoll.OnRagdoll += StartRagdollPart; }