I have javascript for first person melee attack, but it does not works on third person, can any body help me out with it, i need it working on third person.
the code is just for calculating the distance but it doesnt work on third person:
var TheDamage: int = 50;
var Distance: float;
function Update()
{
if (Input.GetButtonDown("Fire1"))
{
var hit: RaycastHit;
if (Physics.Raycast (transform.position, transform.TransformDirection(Vector3.forward), hit))
{
Distance = hit.distance;
hit.transform.SendMessage("ApplyDamage", TheDamage, SendMessageOptions.DontRequireReceiver);
}
}
}
↧