Created
January 23, 2018 07:45
-
-
Save Drenerdo/766328882334b6fd0b45fb5f9b66a368 to your computer and use it in GitHub Desktop.
BodyCollision Script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class BodyCollision : MonoBehaviour | |
{ | |
public StairDismount stairDismount; | |
void OnCollisionEnter(Collision col) | |
{ | |
if (col.gameObject.tag == "Weapon") | |
{ | |
if (gameObject.tag == "Head") | |
{ | |
Debug.Log("Head hit!"); | |
//find the RagdollHelper component and activate ragdolling | |
RagdollHelper helper = GetComponent<RagdollHelper>(); | |
helper.ragdolled = true; | |
//set the impact target to whatever the ray hit | |
impactTarget = hit.rigidbody; | |
//impact direction also according to the ray | |
impact = ray.direction * 2.0f; | |
//the impact will be reapplied for the next 250ms | |
//to make the connected objects follow even though the simulated body joints | |
//might stretch | |
impactEndTime = Time.time + 0.25f; | |
} | |
if (gameObject.tag == "Spine") | |
{ | |
Debug.Log("Spine Hit!"); | |
} | |
if (gameObject.tag == "Hips") | |
{ | |
Debug.Log("Hips hit!"); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment