- Home /
How do you create a Deus Ex Health System?
How do you create a health system like the one in Deus Ex? Except with more body parts. Here's the total:
Upper Head(Cranium); Lower Head(Jaw); Spinal Cord; Neck; Chest; Stomach; Upper Back; Lower Back; Shoulder; Arm; Elbow; Forearm; Wrist; Hand; Groin; Thigh; Knee; Leg; Ankle; Foot
Anyway, if anyone decides to help, thanks in advance.
Not familiar with it - would you need to real-time check for collisions against each body part with a weapon or just select a target region and then apply damage?
I don't know. That's why I'm asking. I actually don't have Unity yet, because I don't have a comp and the Internet Cafes here are too slow, but I'm trying to learn. But since I don't have Unity, I can't learn from experience, so this is the next best thing besides tutorials.
Not trying to put a downer on your intentions, however with your current level of experience, something to this sort of complexity might be slightly to advanced.
What you're looking to is entirely possibly within Unity, using the suggestion made by getyour411. However I would personally recommend that when you do manage to get a copy of Unity, that you work your way through the countless number of tutorials out there, offering examples of how to make a simple game from scratch.
After a few tutorials you will probably be able to answer this simple question yourself. ;-)
Answer by save · Aug 31, 2013 at 01:48 PM
One way to do it is to create a Body- and a BodyPart class. The Body class holds information about each body part where you would assign each element to its corresponding part.
To give you an idea of the concept, the class would look something like this:
class Body {
var health : float = 100;
var minHealth : float = 0;
var maxHealth : float = 100;
var head : BodyPart;
var chest : BodyPart;
var armLeft : BodyPart;
var armRight : BodyPart;
var legLeft : BodyPart;
var legRight : BodyPart;
// etc...
}
class BodyPart {
var collider : Collider;
var health : float = 100;
}
Changing the main health of a body object would look something like this:
function AlterHealth (healthChange : float, body : Body) {
// Additively alter the health of passed body
body.health = Mathf.Clamp(body.health+healthChange, body.minHealth, body.maxHealth);
}
Creating a body object with these abilities would look like this: var body : Body = new Body();
Each part of the body would have a collider which you assign to the body object. You would want to catch collisions with a body part collider, preferably with a script which sends information to the main body script. Something like this:
var thisBody : BodyScript; // The main Body Script of this object
function OnCollisionEnter (collision : Collision) {
if (collision.collider.CompareTag("Collidable Object")) {
BodyScript.AlterBodyPartHealth(thisBody.body, collider, collision.relativeVelocity.magnitude);
}
}
Where the BodyScript would have a function, AlterBodyPartHealth, which receives the part and handles it correspondingly to the body object.
static function AlterBodyPartHealth (body : Body, col : Collider, healthChange : float) {
// Main health change for non-vital limbs
var mainHealthChange : float = healthChange*.25;
// Additively alter the health of passed body's body part and change the mainHealthChange for vital body parts
switch (col) {
case body.head.collider: body.head.health -= healthChange; mainHealthChange*=4; break;
case body.chest.collider: body.chest.health -= healthChange; mainHealthChange*=2; break;
case body.armLeft.collider: body.armLeft.health -= healthChange; break;
case body.armRight.collider: body.armRight.health -= healthChange; break;
case body.legLeft.collider: body.legLeft.health -= healthChange; break;
case body.legRight.collider: body.legRight.health -= healthChange; break;
}
// Alter the main health as well
AlterHealth(mainHealthChange, body);
body.health = Mathf.Clamp(body.health+healthChange, body.minHealth, body.maxHealth);
}
I strongly suggest to start with something easier and work your way through understanding of the built-in classes and their correlation before you tackle something like this. There's a lot around this as well, handling collisions the correct way is just one tricky part to become friends with at first - as well as creating the skinned mesh avatar.
For more information about how you solve the GUI to this, please see the GUI Scripting Guide and ask another question if you have trouble when you're there and we'll help you through it.
Answer by fherbst · Aug 31, 2013 at 01:00 PM
Basic concept: Each body part has its own health and collision detection. Additionally, there is some general handler to manage them(resetting, healing etc.). Collision might mean bullets, swords, or just clicking. But you have to think about getyour411's comment, that's not a matter of implementation but of game design (how does the principle work, independent of Unity).
Your answer

Follow this Question
Related Questions
Adding fall damage with the default FPSWalker 1 Answer
Making an HUD 3 Answers
C# issue, health, and destroying affect other objects. 3 Answers
Health Bar Division like in MOBA 1 Answer