Quantcast
Channel: Questions in topic: "ragdoll"
Viewing all articles
Browse latest Browse all 565

force before ragdoll

$
0
0
I have a character that has a head collider on it, so when it is shot in the head, it accesses another script that turns it into a rag doll. below is the part of the script that receives the shot and sends it upward. I tried a few things, but didn't have any success. below that is the part of the other script that has the detonate function. if(hit.collider.gameObject.name == GameObject.FindWithTag("HeadCollider").gameObject.name) { hit.rigidbody.AddForceAtPosition(force * direction, hit.point); //AddForceAtPosition(force * direction, hit.point); Debug.Log("That was a headshot"); // if(hit.rigidbody) // { // hit.rigidbody.AddForceAtPosition(force * direction, hit.point); // } hit.collider.SendMessageUpwards("Detonate",SendMessageOptions.DontRequireReceiver); function Detonate () { // Destroy ourselves Destroy(gameObject); // Play a dying audio clip if (dieSound) AudioSource.PlayClipAtPoint(dieSound, transform.position); // Replace ourselves with the dead body if (deadReplacement) { var dead : Transform = Instantiate(deadReplacement, transform.position, transform.rotation); // Copy position & rotation from the old hierarchy into the dead replacement CopyTransformsRecurse(transform, dead); } }

Viewing all articles
Browse latest Browse all 565

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>