Hey I am making an FPS alien game. I have no clue how to get hurt when the "alien" hits me and how to make him die when I hit him. I have no script and would like one since I am a noob. Thanks
The tutorials do a good job explaining this. Here is the 3rd Person Platformer.
Basically here is the idea. The script below would go on the enemy
var damage : int = 5;
var damageRadius = 1;
var player : Transform; //drag the player here in the inspector.
function Update () {
if(Vector3.Distance(transform.position, player.position) <= 1) {
//Alien Attacks
player.BroadcastMessage("ApplyDamage", damage, SendMessageOptions.DontRequireReciever);
}
}
Create another script for the player with the following:
//This next function is a script on the player.
var health = 10;
function ApplyDamage(damage : int) {
health -= damage;
if(health <= 0) {
Die();
}
}
function Die () {
//Respawn Player if wanted.
Destroy(gameObject);
}