Quantcast
Channel: Questions in topic: "enemy"
Viewing all articles
Browse latest Browse all 1488

How to make an enemy ragdoll on death?

$
0
0
I'm having trouble figuring out how to get an enemy to ragdoll when hp drops below zero. I have a basic code that enables ragdolls when scene starts but I need it enabled after enemy is killed but while they are alive they are rigid. Any help appreciated, thanks! Side note: fairly new to unity and coding. public int maxHp = 10; private int hp; Component[] bodyparts; void Start() { hp = maxHp; bodyparts = GetComponentsInChildren(); } public void Damage(DamageInfo info) { if (hp <= 0) return; hp -= info.damage; if (hp <= 0) Die(); } void Die() { Destroy(gameObject); } }

Viewing all articles
Browse latest Browse all 1488

Trending Articles



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