Unity Ninja Unity 3D Forum
To have exclusive access to all downloads, recourses and links within this forum, a free registered account is required. Just a heads up Wink
Go down
Member [Lv. 0]
Member [Lv. 0]
Posts : 1
Points : 1088
Rep : 0
Join date : 2015-07-31
View user profile

Sword damge to enemy when touching !

on Thu Nov 19, 2015 4:55 am
my problem is, i want to make my player possibility to damage the ennemy and kill them so i make a script when ennemy touch player it hurt them. Please help ?

Enemy Health Script :

var Health = 100;
var deadReplacement : Rigidbody;
var GOPos : GameObject;

function ApplyDamage (TheDamage : float) {
   if (Health <= 0.0)

   // Apply damage
   Health -= TheDamage;
   // Are we dead?
   if (Health <= 0)

function Replace() {

   // If we have a dead barrel then replace ourselves with it!
   if (deadReplacement) {
      var dead : Rigidbody = Instantiate(deadReplacement, GOPos.transform.position, GOPos.transform.rotation);
      // For better effect we assign the same velocity to the exploded barrel
      dead.rigidbody.velocity = rigidbody.velocity;
      dead.angularVelocity = rigidbody.angularVelocity;
   // Destroy ourselves

Back to top
Permissions in this forum:
You cannot reply to topics in this forum