I created this script:1322551–62887–$EnemyLogic.js (102 Bytes)
but when i attack a capsule just to test, I can only hit the object to the right not straight on… any help?
I created this script:1322551–62887–$EnemyLogic.js (102 Bytes)
but when i attack a capsule just to test, I can only hit the object to the right not straight on… any help?
#pragma strict
var Health = 100;
function ApplyDamage (TheDamage : int)
{
Health -= TheDamage;
}
sorry bout that
here is my melee:
#pragma strict
var TheDamage : int = 30;
var Distance : float;
var MaxDistance : float = 1.5;
function Update ()
{
if (Input.GetButtonDown("Fire1"))
{
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);
}
}
}
}