- Home /
Enemy fall apart on projectile impact
I am wanting to write a script that would identify what part of a humanoid model (made simply out of unity Game objects) is hit by a projectile. At which point the 'body part' will fall apart or fly off. I would like to write it myself just am having trouble finding anything to start me on the right track . although any help will be appreciated. thanks
You could give each body part gameobject a different Tag (Head, Torso etc.), or a descriptive name, or a script that holds a variable identifying the type of body part.
Each body part object also needs a collider, of course.
For the project to regsiter hits, it needs a rigidbody, a collider and of course a simple script using the OnCollisionEnter or OnTriggerEnter methods. Check the User API for more information.
If a body part should fall off or fly away, they need rigidbodies as well so you can use AddExplosionForce and similar methods designed for rigidbodies. It would be best in this case to make the layer the bodyparts are in to not register collisions between themselves.
Your answer
![](https://koobas.hobune.stream/wayback/20220612034035im_/https://answers.unity.com/themes/thub/images/avi.jpg)