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

You are not connected. Please login or register

Unity Ninja Unity 3D Forum » General Dicussions » Request » Sword damge to enemy when touching !

Sword damge to enemy when touching !

View previous topic View next topic Go down  Message [Page 1 of 1]

1 Sword damge to enemy when touching ! on Thu Nov 19, 2015 4:55 am


Member [Lv. 0]
Member [Lv. 0]
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

View user profile

View previous topic View next topic Back to top  Message [Page 1 of 1]

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