- Home /
Health Functions in Unity?
I've been looking through the Unity Scripting reference and haven't been able to find any commands dealing with a players health, are these included in Unity or do I need to make my own system?
Answer by doomprodigy · Feb 16, 2011 at 04:56 AM
As DaveA said, You have to program it yourself, Health is straightforward, Try to be a lot more specific with your questions.
Here is some health (C#)
public float Health = 100f;
There is health, merely a float. Now depending on what your doing you can add health, subtract health, render some gui text of health variable on the screen, or render images of a health bar on your screen depending on what amount of hp you have.
Now if you are curious as to how you subtract or add health or render it on the screen ask a question with some code your have written that is not working or just ask how you do it.
Cheers, Aaron Lewis
well no I was just curious I thought for sure Unity would have something like that. Now that I know theres no function I can make a system real quik . :)
thank you both
I gave you both up but gave the answer to Aaron cuase he only has 228 points lol
Answer by DaveA · Feb 16, 2011 at 04:25 AM
Your own system. It's all up to you if someone/something lives or dies and how. Have fun!
Answer by Design3.com · Feb 17, 2011 at 12:42 AM
Yeah, just create your own variable and use it as you see fit to make calculations, display onscreen, etc.
var health : float = 100;
or
public float Health = 100f;
Design3 has a walkthrough here: http://www.design3.com/unity/fundamentals/unity-gameplay-a-scripting-primer/item/25-u1012-chapter-04-player-state-machine#comment38
Your answer
Follow this Question
Related Questions
Enemy Health Problem 2 Answers
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
A node in a childnode? 1 Answer
When my button is pressed the action reapeats 1 Answer
Spawning Error.. 0 Answers