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 » HELP » Help (General) » Animation, and damage

Animation, and damage

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

1 Animation, and damage on Fri Mar 21, 2014 8:55 pm

MDTQP


Member [Lv. 1]
Member [Lv. 1]
Hey guys, so i've got two scripts. A script to represent basic melee and another to show that when u do the melee the guy loses damage. There seems to be something wrong though. This first one is my melee script.
#pragma strict

var TheDamage : int = 50;
var Distance : float;
var MaxDistance : float = 1.5;
var STANDARDKNIFE : Transform;

function Update()
{
if (Input.GetButtonDown("Fire1"))
{
STANDARDKNIFE.animation.Play("Knife Attack");
var hit : RaycastHit;
if (Physics.Raycast (transform.position, transform.TransformDirection(Vector3.forward), hit))
{
Distance = hit.distance;
if (Distance < MaxDistance)
{
hit.transform.SendMessage("ApplyDamage", TheDamage, SendMessageOptions.DontRequireReceiver);
}
}
}
}

That script was the melee script and there is two problems im having with it. One, the enemy isn't taking damage (enemy script soon) and two, the animation wont play because "the variable STANDARDKNIFE has not been assigned.

(Enemy Script)
var Health = 100;

function Update ()
{
if(Health <= 0)
{
Dead ();
}
}

function ApplyDamage (TheDamage : int)
{
Health -= TheDamage;
}

function Dead ()
{
Destroy (gameObject);
}
any other details i should tel you: Using FPS kit, animation name is Knife Attack..... anything else?

Thanks in advance! Very Happy

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