- Home /
How to make my Player take damage from prefab?
var curHealth = 100; var maxHealth = 100; var healthtext : GUIText; var HitDamage : boolean; var deathbomb : GameObject;
function OnControllerColliderHit(hit: ControllerColliderHit){
if(hit.gameObject.name == "Enemy");
{
HitDamage == true;
curHealth -= 10;
}
function Update(){ healthtext.text = "Health " + curHealth + " / " + maxHealth; if(curHealth <=0){ Destroy(gameObject); } } }
Duplicate Question : http://answers.unity3d.com/questions/404732/how-to-make-my-player-take-damage-from-prefab-1.html
Please Delete this Question.
Please be patient if your question/reply doesn't show straight away.
As a new user, your posts and questions are held in a moderator que until it is approved and then it is displayed. When your karma rises, you'll be able to post questions, comments and answers without waiting for someone to approve it.