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

Ragdoll Issue [GIF + SCRIPTS]

$
0
0
https://imgur.com/a/wpijgfx _ I am looking to test a simple ragdoll script, on all the limbs of the character I have a rigidbody and a capsule collider. When a bullet hits this enemy, it activates a death void which allows the rigidbodies to ragdoll. I'd imagine this is a pretty straightforward issue since my script is working correctly, I know it has something to do with the way i setup my character. I'm just getting started learning about the possibilities of ragdoll and would love some senior advice! _ using System.Collections; using System.Collections.Generic; using UnityEngine; public class EnemyController : MonoBehaviour { // Start is called before the first frame update void Start() { SetRigidbodyState(true); SetColliderState(false); GetComponent().enabled = true; } public void Die() { GetComponent().enabled = false; SetRigidbodyState(false); SetColliderState(true); if (gameObject != null) { Destroy(gameObject, 3f); } } void SetRigidbodyState(bool state) { Rigidbody[] rigidbodies = GetComponentsInChildren(); foreach (Rigidbody rigidbody in rigidbodies) { rigidbody.isKinematic = state; } GetComponent().isKinematic = !state; } void SetColliderState(bool state) { Collider[] colliders = GetComponentsInChildren(); foreach (Collider collider in colliders) { collider.enabled = state; } GetComponent().enabled = !state; } }

Viewing all articles
Browse latest Browse all 565

Trending Articles



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